1

I have a Firebase database with a list of users and a list of best friends, a user's best friends can be pulled by using it's userid:

users list:

  • userid
    • user data
  • userid
    • user data
  • ..

best friends list:

  • userid
    • userid of friend
    • userid of friend
    • ...
  • userid
    • userid of friend
    • userid of friend
    • ...
    • ...
    • ...

Is there a way using the Firebase api to get the friend's data in a list instead of a list of userid's of your friends when making the call to get your best friends ? Now i have to do 2 steps (get best friends id's -> loop users for friend's data)

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121

2 Answers2

1

No, there is not. There is no way to achieve this. You need to query your data twice, first time to get best friends id's and second to get the actual data of those friends. You cannot get that list in a single step, using a single query..

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
0

What I think from your description is that you want to perform a join.

There's no official "join" method in the Firebase Database SDK, but you can use multiple listeners to combine data from multiple paths.

https://www.youtube.com/watch?v=Idu9EJPSxiY check out this youtube video it will help

Jainam Jhaveri
  • 1,479
  • 1
  • 18
  • 31