Query where a Firestore Field is contained in a List

Viewed 368

How would I query a field (String) to see if it matches a string in an array. I know you can query an array with something like this:

query.where('venue.id', arrayContains: venueId)
// where venue.id is an List and venueId is a string

But how would I query if 'venue.id' is a string and venueId is a List.

1 Answers

You can achieve this using Query.whereIn:

query.where('venue.id', whereIn: ['id1', 'id2'])

whereIn takes a list of values and if the field you are querying matches any of the values, its document is included in the query.


Learn more.

Related