Using push() method to create new child location without unique key

后端 未结 1 427
南笙
南笙 2020-12-16 21:27

In my firebase web app when new users signup with their email i create a node under their email adress under the root ref

But the problem is using push() method to

相关标签:
1条回答
  • 2020-12-16 22:16

    Calling push generates a location with an auto-calculated key.

    To write a child at a path that you determine the key yourself, you simply call child("key").set(value).

    If you store Firebase Authentication users in your database, the idiomatic way is to store them under their uid.

    var user = firebase.auth().currentUser;
    var usersRef = firebase.database().ref("users");
    if (user) {
      usersRef.child(user.uid).set({ 
        displayName: displayName,
        email: email,
        photoUrl: photoUrl,
        emailVerified: emailVerified
      });
    }
    
    0 讨论(0)
提交回复
热议问题