How do I get the key \"-KLpcURDV68BcbAvlPFy\" when I know the field \"name\" contains \"efg\" in the following structure in Firebase.
clubs
-KLpcURDV68Bc
I've figured out a very easy way to do this. You need to get the auto-generated key before you send it to firebase. So for my project I did something like the following:
var database = firebase.database();
var rootRef = database.ref();
var autoId = rootRef.push().key
rootRef.child(autoId).set({
key: value,
key: value,
key: value,
autoid: autoId
})
Now when i go to my child added function and take a snapshot, I can easily get to snapshot.val().autoid
and store it in a variable or as a button attribute so that I can delete it later.