Scarfacecr
Scarfacecr

Reputation: 11

Flutter Firebase Multiple Document Id StreamBuilder

I have a document id list in my code, I want to use this id list in my new query. How can I enter multiple document id's?

StreamBuilder(
     stream: Firestore.instance.collection("Dersler")
     .document(dersler).collection("Kategori")
     .document(kategori).collection("Test")
     .snapshots(),
     builder: (context, snapshot) {}

The "dersler" string contains: DRk5uDVZwITKqYVLPGP0, E0y2PMnoM8H9WTeObSzi, bpaBAs15EuEMRAUihVC2, g31ZgqRtmIaYVxyTNvqG

Upvotes: 0

Views: 183

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599896

There's no way to pass multiple IDs to the document call in your code. The closest you can get is by performing a collection group query on a path as samthecodingmanb shows in this answer: CollectionGroupQuery but limit search to subcollections under a particular document

So you'd have an in condition on firebase.firestore.FieldPath.documentId() with the document path prefixes for the documents you want to get. But even then you would not be able to include the Kategori in the path, and can only do this for up to 10 documents paths (the limit on an in condition).


If you can't get this approach to work (as I expect), your only alternative would be to perform a separate read for each document ID and merge the results in your application code.

Upvotes: 1

Related Questions