有没有办法在Firestore上的所有文档中更改值? [英] Is there a way to change a value in all documents on firestore?

查看:52
本文介绍了有没有办法在Firestore上的所有文档中更改值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个使用React-native和Firebase创建移动应用程序的初学者.我在许多文档中都有一个值,我想更新所有文档中的值

I'm a beginner creating an mobile app with react-native and firebase. I have a value stored in many documents and i want to update the value in all the documents

我尝试使用.where()子句,但出现错误

i tried with .where() clause but i got an error

firebase.firestore().collection('myCollection').where('myValue','==','oldValue').update({myValue:newValue});

我希望数据会改变,但是我得到了这个警告:

I expected the data changed but i got this warning:

Possible Unhandled Promise Rejection (id: 0):
TypeError: _reactNativeFirebase.default.firestore(...).collection(...).where(...).update is not a function

请原谅我的英语不好

推荐答案

Firestore无法提供一种基于文档的当前值批量更新文档的方法.没有类似SQL的更新位置"类型的语法.您必须首先查询并阅读所有要更改的文档,然后使用它们的新值对其进行更新.

Firestore doesn't provide a way to update documents in bulk based on their current values. There is no SQL-like "update where" type of syntax. You'll have to first query and read all the documents you want to change, then update them with their new values.

这篇关于有没有办法在Firestore上的所有文档中更改值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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