Query a Firestore collection with an array_contains filter

Query a Firestore collection with an array_contains filter

Code sample

Go

query := cities.Where("regions", "array-contains", "west_coast").Documents(ctx)

Java

CollectionReference citiesRef = db.collection("cities");
Query westCoastQuery = citiesRef.whereArrayContains("regions", "west_coast");

Node.js

const westCoastCities = citiesRef.where('regions', 'array-contains',
  'west_coast').get();

Python

cities_ref = db.collection(u'cities')

query = cities_ref.where(u'regions', u'array_contains', u'west_coast')