chichi
chichi

Reputation: 3301

Flutter: Firestore how to retrieve all the collections belong to a document?

I have a collection tree like

- game (collection)
   - FPS (document)
      - CS:GO (collection)
      - Valorant (collection)
   - etc (document)

I am trying to retrieve all the collections from FPS but firebase is returning empty map {}.

Do I really have to make .get() operation to each collections, even if I just need collections that belong to FPS?

Upvotes: 0

Views: 39

Answers (2)

Alan Cesar
Alan Cesar

Reputation: 400

Try to change your structure to:

 Genres(collection)
     FPS(document)
        Games(collection)
          CS:GO(document)
          Valorant(document)
     MOBA(document)
        Games(collection)
          LOL(document)
          Dota 2(document)

For each game genre, you will have a collection of games. In this way you can get all documents inside ("Genres/FPS/Games")

Upvotes: 1

Huthaifa Muayyad
Huthaifa Muayyad

Reputation: 12383

Short answer: yes.

Currently, you can't query multiple collections at once.

Upvotes: 1

Related Questions