2
votes

I am not sure if this is possible in fire base as I wish, My database is

    User_ID: ID
        online:true/false
        friends: 
               ID: Name 
               ID: Name 

User login in, retrieve his information including friends Ids.

My question can I get All users with some IDs (User friend Ids) who have online true.

Looks like 2 queries: (Where friends ids(multiple ids) = ??? and online = true)

I have workaround solution for this but I don't like it As i have to get all Online users (friends and none friends) and keep only friend, in this case I will retrieve data which I dont want in this case.

1
If you have to make queries you should use Cloud Firestore Database , it would make easier for you . - Wasim

1 Answers

1
votes

if you want to use just single query yes there is an method for realtime database

databaseRef.orderByChild("online").equalTo(true);

And this will return all the keys/items of parent from databse which have online:true child:value under them

https://firebase.google.com/docs/database/admin/retrieve-data#section-complex-queries