Setting custom key when pushing new data to firebase database

后端 未结 10 593
野的像风
野的像风 2020-12-13 12:22

Well, I am new to Firebase and I want to have my own keys while pushing new data to database.

Problem:

FireBase.push().setValue(mapped_values);
         


        
10条回答
  •  感情败类
    2020-12-13 13:03

    You can create a custom key using setValue() even if the root contains many children for example if 'Users' is the root and you want to add users with email as a key it will be like this

    firebase.child("firebase url").child("Users").child("user_1 email").setValue(...)
    
    firebase.child("firebase url").child("Users").child("user_2 email").setValue(...)
    

    etc

    Hope this helps.

提交回复
热议问题