Reputation: 125
i am need custom key name in firebase database this my code
firebase.database().ref("chat").child('aaa')
firebaseRef.push({
text : 'bbb'
})
result enter image description here
Upvotes: 1
Views: 1609
Reputation: 3804
Yes, you can store data under custom key name (however, you'll have to verify the uniqueness of that key yourself).
Your code will look something like -
var firebaseRef = firebase.database().ref("chat").child('aaa').child('ccc');
firebaseRef.set({
text : 'bbb'
});
You can further read up on this at Firebase Realtime database - Read and Write.
This will give you the structure that you want (as per your image).
Upvotes: 2
Reputation: 13129
To have it like your image you can do this, just add a new child where to store your text and remove .push
since that will push randomly generated value to store the text
firebase.database().ref("chat").child('aaa').child('ccc')
firebaseRef.set({
text : 'bbb'
});
Upvotes: 1