0

Firebase (javascript): How can I store uid as a push key?

In other word, how can I associate uid stored in user object with each push keys stored in realtime database? I know that when I store data in realtime database using push(), firebase auto-generates a unique key (which is different from uid in user object) and store it as a node of those data.

2nd Aug 2018, 5:19 PM
Sotoku Tomotsugu
Sotoku Tomotsugu - avatar
1 Resposta
+ 1
You are right to say that the push keys are auto-generated by firebase. These keys gets generated when we use push() method. The solutions to your Problem is to not to use the push method. You need to use the set method. Something on the lines of: firebase.database().ref('users/' + uid).set({     username: name,     email: email,     profile_picture : imageUrl   }, function(error) {     if (error) {       // The write failed...     } else {       // Data saved successfully!     }   }); }
13th Aug 2018, 2:13 PM
Ketan Yekale
Ketan Yekale - avatar