有没有办法在Firestore上的所有文档中更改值?

有没有办法在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.