looking to update a field in an array that has map objects that look like this:
somearray
(map objects)
obj0_____id:1
_____returned: false
obj1_____id:2
_____returned: false
code I'm trying
somefunction = () => {
let bookid = document.getElementById('bookid').value;
db.collection('books').where('field.id', '==', bookid).get().then(querySnapshot => {
querySnapshot.forEach(doc =>
doc.update({
"field.returned": true
})
)
}
)
}
Firestore does not make it possible to query documents for map fields in an array. The only way you can search an array is for exact item contents, which means you have to know the value of the entire object and all of its properties.
If you want to search on that "id" map field, you will have to do something else. For example, you could create a new top-level document field that contains just an array of ID values, and query that with an array-contains query.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.