Reputation: 47
If I have a simple collection Cats
:
Cats:
Meowy:
colors: ['orange', 'white']
Purro:
colors: ['black', 'orange']
Bob:
colors: ['black']
How can I query only the documents that their colors
field contains orange (in JavaScript)?
Upvotes: 1
Views: 69
Reputation: 161
This seems it can work however I haven't tried in my local. Also check the firebase documentation :
https://firebase.google.com/docs/firestore/query-data/queries#web_3
var catRef = db.collection("Cats");
catRef.where('colors', 'array-contains',
'orange');
Upvotes: 1