I'm trying to populate my Firebase real-time database with multiple users like this structure:
users userId: "xn73kdnx8393jxnekd" //this will come from firebase auth userEmail: "[email protected]" //this will come from firebase auth
Every time I create a new user during login, Firebase Database adds the user but overwrites the past user and it will not create the "userEmail" child and store the email address. So my database looks like this currently and only has 1 entry (the latest one):
users userId: "xn73kdnx8393jxnekd"
My Firebase Authentication has multiple users but the database will only store the latest one with no email address.
My question is two parts:
1. Why does my database just overwrite the existing entry with the latest entry and how do I add multiple users?
Specs: I'm using Firebase Auth and Firebase Database gradle 19.0.0
here is the code
//Adding users information to Firebase Database from Firebase Auth database = FirebaseDatabase.getInstance().reference var userID = firebaseAuth?.currentUser var fireUserID = userID?.uid var userEmail = userID?.email database.child("users").child("userId").child(fireUserID.toString()).child("email").child(userEmail.toString()).setValue("true")
Thanks for Taking a look