且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用flutter更新Firestore中所有文档的单个字段?

更新时间:2023-02-14 08:53:02

Firestore不提供类似于SQL的"update where"该命令可一次更新所有内容,因此您将必须:

Firestore doesn't offer a SQL-like "update where" command that updates everything at once, so you will have to:

  1. 查询要更新的文档
  2. 迭代每个 DocumentSnapshot 并使用以下方法获取其DocumentReference对象引用属性
  3. 对于每个文档,更新该字段及其新价值
  1. Query for the documents to update
  2. Iterate each DocumentSnapshot and get its DocumentReference object using the reference property
  3. For each document, update the field with its new value