Reputation: 1320
I'm newbie in firebase database.
I make some relations key in firebase like this:
chats/conversation_key
members/conversation_key/array_of_user_uid
messages/conversation_key/array_of_messages
The question is: How to find members key if i already know user uid?
IE: I want to find -KgePX_tcbDz9fU-kAZT
in members if i already have user uid jEIAfqDpJjWWUUXaecSmMk3U7vu1
Upvotes: 2
Views: 21001
Reputation: 101
var firebaseRef = firebase.database().ref("members");
firebaseRef.orderByChild(userKey).equalTo(true/false).on("child_added", function(Data){
console.log(Data.val(), Data.key);
}
i am assuming that you are already aware of on or once method and child events also, if not then read them(documentation), will help you a lot, otherwise above code will do your job
Upvotes: 4