Skip to content Skip to sidebar Skip to footer

Firestore Query - Array Contains All

My use case involves filtering the Firestore documents with 'array-contains-all' whose name I made up for the purpose of this question. However, the 'array-contains-any' already ex

Solution 1:

As long as you are working with list type fields as you are now, there isn't going to be a way to query that you would find efficient. If you copy the data into a new map type field, it will be possible.

facilities: {
    'kettle':true'microwave':true'cooker':true
}

With this map containing known boolean values, you can query like this:

firestore
    .collection("your-collection")
    .where("facilities.kettle", "==", true)
    .where("facilities.microwave", "==", true)
    .where("facilities.cooker", "==", true)

Post a Comment for "Firestore Query - Array Contains All"