Reputation: 49
I have to change key when I push data to firebase realtime database. How can I change ? I'm trying push data without key.
My Database :
Deneme/ driverid/( key ) {data ....}
My Code:
var driverid =getInputVal('driverid');
var newmesajRef = mesajsRef.child(driverid).push();
newmesajRef.set({
driverid: driverid,
Upvotes: 0
Views: 756
Reputation: 317362
The whole point of push()
is to auto generate a unique key. If you know exactly where you want to write your data, just build a reference to the location you want, set()
your data directly at that location, and don't use push()
at all.
So for exammple, this will write the new data straight under the driverid
node:
var driverid =getInputVal('driverid');
var newmesajRef = mesajsRef.child(driverid)
newmesajRef.set({
driverid: driverid,
...
Upvotes: 3