Skip to content Skip to sidebar Skip to footer

How To Do CRUD Operations In Firebase With CurrentUserId?

I'm creating a simple website and i'cant use firebase realtime databases crud operations with currentUserId. My auth system working good; i can signIn/signUp/signOut on database.

Solution 1:

Are you asking how to write data in a location that is specific to the current user? If so:

var currentUser = firebase.auth().currentUser;
var DataRef = firebase.database().ref('users/' + currentUser.uid + '/exercises/');

Note that this only works if the current user is guaranteed to be already signed in. If you can't guarantee that, put the above code in an auth state listener.


Post a Comment for "How To Do CRUD Operations In Firebase With CurrentUserId?"