1

I'm trying to query 2 collections from firebase and put it in a streambuilder. There are lot of questions like this,but a lot of them are unsolved,or I just didn't really found the right one.

So,I got a users,and a salons collection in Firebase. user1 contains his name,age,etc and he have another collection called favsalons. In salons are the description of salons like name,owner,etc In app I want to list out the favsalons with their datas.

In SQL it would look something like this : Select salons.name,salons.owner From salons,user Where userID=user1 and favsalonsID=salonsID Since I'm new to flutter,and to the non SQL databases,I got no clue how to do it.

Is there a simple solution?

Bojke
  • 646
  • 1
  • 6
  • 21
  • https://stackoverflow.com/questions/36571924/how-can-i-merge-multiple-streams-into-a-higher-level-stream, https://www.youtube.com/watch?v=-7EaYUIRBmc – Günter Zöchbauer Jan 24 '19 at 18:43

2 Answers2

1

You can't... You need to modify the structure of your data. Watch the firebase team explanation.

Jairo R. Flores
  • 724
  • 4
  • 11
0

Solved with simply nesting two streambuilders.

Bojke
  • 646
  • 1
  • 6
  • 21
  • 1
    jajajajaja That's not merging! – Jairo R. Flores Feb 07 '19 at 15:13
  • 1
    @Bojke could you show how you did that, i have a problem like this, i have a colection of object that references another object in another collection by key/id, now i just want to know how join to get for each object get its relationed object in the other colletion. – Jorge Vieira Feb 09 '19 at 12:56
  • 1
    @JorgeVieira used 2 streambuilders like when you for example nest 2 for loops,then used a loop to filter the snapshots,and put it in a list. – Bojke Feb 14 '19 at 15:36
  • Providing more details to your answer would have been really useful. – Francisca Mkina Mar 17 '21 at 16:59
  • @Bojke can you share your code? I couldn't build the structure. – Tim's Jan 03 '22 at 02:23