javascript - 如何使用where和update
问题描述
我正在尝试这样做:
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”。有任何想法吗?
解决方案
Firestore 不支持更新查询。要更新文档,您需要知道其完整路径。因此,要更新与查询匹配的所有文档,您需要:
- 对数据库执行该查询
- 循环生成的文档
- 依次更新每个文档
另见:
推荐阅读
- r - 如何计算 R 中的 p 值?
- angular - 使用 angular-oauth2-oidc 的 Angular 和 OAuth 2 授权代码授权流程
- java - 使用基本身份验证在 Java 中获取和发布 API 调用
- arrays - 空手道:我可以迭代 Json 数组响应并执行一些条件语句吗
- c# - 从 base64 超时请求转换文件
- python - 为什么python在执行完成后会丢弃错误
- python - Google Colab - 如何比较两张照片
- node.js - 在 NodeJS 中从 XML 生成友好的 JSON
- html - HTML 中心图像和下面的文本段落
- java - Java:重写字节码以添加接口的安全性