Unable to add multiple Firebase Database categories and keeps overwriting existing entry

by jason_proger   Last Updated October 09, 2019 15:26 PM

I'm trying to populate my Firebase real-time database with multiple users like this structure:

   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):

    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?

  1. Why does my database refuse to add the "userEmail" child?

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

Thanks for Taking a look

Related Questions

Iterating through a Firebase database

Updated January 22, 2019 04:26 AM