【问题标题】:How to use where and update [duplicate]如何使用where和更新[重复]
【发布时间】:2020-07-30 12:34:54
【问题描述】:

我正在尝试这样做:

database.collection('UsuariosDev').where('Telefono', '==', textInput.current.value)
    .update({
        citas: firebase.firestore.FieldValue.arrayUnion(database.doc('NegociosDev/Peluquerías/Negocios/PR01/citas/' + docRef.id))
})

从集合“UsuariosDev”中获取文档,其中“Telefono”等于“textInput.current.value”,然后更新它。但似乎我不能在“where”旁边使用“update”。有什么想法吗?

【问题讨论】:

  • 这个反应相关吗?
  • 嗯,是web,不知道firebase是否在平台之间使用相同的代码。

标签: javascript google-cloud-firestore


【解决方案1】:

Firestore 不支持更新查询。要更新文档,您需要知道其完整路径。因此,要更新与查询匹配的所有文档,您需要:

  1. 对数据库执行该查询
  2. 遍历生成的文档
  3. 依次更新每个文档

另见:

【讨论】:

    猜你喜欢
    • 2014-10-09
    • 2015-12-11
    • 2011-01-28
    • 1970-01-01
    • 2018-06-22
    • 1970-01-01
    • 1970-01-01
    • 2014-12-28
    • 2021-05-17
    相关资源
    最近更新 更多