How to use where and update [duplicate]

守給你的承諾、 提交于 2021-01-28 19:46:32

问题


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:

  1. Execute that query against the database
  2. Loop over the resulting documents
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!