Brandon Pillay
Brandon Pillay

Reputation: 1166

How to perform a query in Firestore string field to match against multiple values?

I have a collection in Firestore that has a field status which is either "COMPLETE" "INCOMPLETE" or "ON HOLD"

How would I perform a query that only returns the documents matching "COMPLETE" and "INCOMPLETE"?

  FirebaseFirestore.instance.collection('tasks')
    .where('status', isEqualTo: 'COMPLETE')
    .where('status', isEqualTo: 'INCOMPLETE');

Upvotes: 1

Views: 210

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50830

You are looking for whereIn operator which will fetch documents where the provided field (in this case status) has either of the values provided in the array/list passed:

FirebaseFirestore.instance.collection('tasks').where('status', whereIn: ['COMPLETE','INCOMPLETE']);

Upvotes: 2

Related Questions