根据查询更新Cloud Firestore中的文档 [英] Updating documents in Cloud Firestore based on a query

查看:85
本文介绍了根据查询更新Cloud Firestore中的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用包含where子句的firebase cloud函数设置值?

is it possible to set values with firebase cloud function that includes a where clause?

例如

admin.firebase.firestore().collection('Accounts').where("imagePathName", '==', docNamed).set({
  original: 'trial'
});

这给我一个错误.

推荐答案

您可以调用

You can call set() to create or update a document represented by a DocumentReference type object.

查询没有set方法.相反,您必须使用从查询中获取所有文档. get()获取 QuerySnapshot ,然后进行迭代,然后分别在每个文档上调用set().

A query doesn't have a set method. You would instead have to obtain all the documents from the Query using get() to obtain a QuerySnapshot, iterate that, then call set() on each document individually.

这篇关于根据查询更新Cloud Firestore中的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆