The Firebase Realtime Database does not track the position of nodes in their parents, nor does it return such a position in query results. This means the only way to determine the position of a child within a set of child nodes, is to retrieve all child nodes before the one you're looking for.
.ref("users")
.orderByChild("email")
.endAt(myEmail)
.once("value", snapshot => {
var index = 0;
snapshot.forEach(function(childNode) {
if (childNode.child("email").val() === myEmail) {
console.log("Database Position", index);
}
else {
index = index + 1;
}
});
}
Since you commented that you're trying to create a leaderboard, see:
I'd also recommend checking out Dan's answer on Leaderboard ranking with Firebase, which also shows ways to store each player's rankings. While that post is about Firestore, the same principles and considerations apply when implementing a leaderboard on Firebase's Realtime Database.