How to query an array in a firebase firestore doc, where the array must contain each item in the query.
I'm trying to create searchable categories on docs in a collection. I used an array to store the categories as strings. The issue is I can't figure out how to query the collection for docs that contain multiple categories like: [“category1”, “category2”], excluding any docs that don't contain both of these categories. So far from what I've seen in the documentation, I can only query for docs that have either of them. For example:
query(collectionRef, where('categories', 'in', ['category1', 'category2']));
This would return a doc that has either or both categories. I need a query that returns docs that have both categories. Something like:
query(collectionRef, where("categories", "array-contains", "category1", "and", "category2"))