How do I retrieve the random ID key generated by Firebase?
For example, if I have this:
users
│
├──── KT4NTZTzFduj3DNLQgg
│ │
│ ├──── uid: "7ZLldIsRu3NQMOb6"
│ └──── username: "John"
│
│
└──── TO39dsjk2wREF34kmcs // I want this
│
├──── uid: "455klfmckjsnenk2sxkm2"
└──── username: "Micheal"
I want to get the key which holds a username with value equal to Micheal.
firebase.database()
.ref('users')
.orderByChild("username")
.equalTo("Micheal")
.once("value",
function (snapshot) {
// what should I write here ??
});