问题
I'm trying to do this:
database.collection('UsuariosDev').where('Telefono', '==', textInput.current.value)
    .update({
        citas: firebase.firestore.FieldValue.arrayUnion(database.doc('NegociosDev/Peluquerías/Negocios/PR01/citas/' + docRef.id))
})
Get the doc from the collection "UsuariosDev" where "Telefono" equals "textInput.current.value", and then update it. But it seems like I can't use "update" next to "where". Any ideas?
回答1:
Firestore doesn't support update queries. To update a document you need to know its full path. So to update all documents matching a query, you'll need to:
- Execute that query against the database
- Loop over the resulting documents
- Update each document in turn
Also see:
- Way to query and update data in Firestore
- update cloud firestore document without id
来源:https://stackoverflow.com/questions/63173304/how-to-use-where-and-update