Reputation: 1848
Is it possible when adding data manually to the Firebase database, through the dashboard, to let Firebase give each new object an unique key?
Upvotes: 5
Views: 4220
Reputation: 137
To create a randomly generated key you need to use childByAutoId()
This will return a Firebase reference you could use and which will return the key with it's .key property
let createAutoID = FIRDatabase.database().reference().child("orders").childByAutoId()
createAutoID.child("someOtherChild").setValue()
See documentation here
Upvotes: 0
Reputation: 138944
No, you cannot. To achieve this, you need to use the push()
method programmatically. This method will generate a unique key that can be saved in your database and used later in your project.
Please see official documentation regarding saving data into a Firebase database.
Hope it helps.
Upvotes: 6