Flutter Firebase where query

Viewed 1114

Lets imagine I have a list with Document ids e.g

List documentIds = ["Tj4EB68R1CwBYKPfWzcm","fExzUQbpzjEbGyE8mKDa","yPQvLLN7hkDFCjKN6mky"];

Now I want to get all Documents that match that id.

How can I do that?

1 Answers

You're looking for a whereIn query, which looks like this:

FirebaseFirestore.instance
  .collection('yourdocuments')
  .where(FieldPath.documentId, whereIn: documentIds)
  .get()
  .then(...);

The list of document IDs can be up to 10 long, so if you have more than 10 document IDs you'll need to run multiple queries and merge the results in your application code.

See also:

Related