In Cloud Firestore I am needing to find matches in an array that contains maps using the array-contains
query.
I can very easily match direct strings, numbers etc however it always fails when the values of the array is a map. The documentation doesn't allude to is this is possible or not.
Here is an example of some data
{
data:
[
item_1: {...},
item_2: {...}
]
}
and here is an example of the query
db.collection("list")
.where("data", "array-contains", "item_1")
.get()
.then(collectionRef => {
//do something with collection
})
I am expecting the array-contains to match the top value (item_x) of the map, at the moment it doesn't match this. I assume this is because it wants to match the entire content of the map as the "value" of the array item.
Any help would be appreciated. I might have to re-think my data structure if this is not possible. For context I am using this in a cloud function to update items (they are a reference to a doc) in an array when their original doc is updated.