【问题标题】:How can I update document firestore flutter如何更新文档 Firestore 颤振
【发布时间】:2021-02-13 15:34:52
【问题描述】:

如何通过添加所有注册用户 id 作为更新文档的字段来更新文档?

【问题讨论】:

    标签: flutter dart google-cloud-firestore


    【解决方案1】:

    首先,请不要问更容易找到解决方案的问题,这些问题已经得到解答。如果您想在这里提问,请先在 google 上搜索您的问题,如果您找不到任何相关信息,则可以在这里提问。

    那是代码,你可以像这样更新你的日期:

    FirebaseFirestore.instance.doc(yourDocumentPath).update({
      //Write just value which you need to update, like a:
      'username': 'This is my new Username',
    });
    

    或者像这样:

    CollectionReference users = FirebaseFirestore.instance.collection('users');
    
    Future<void> updateUser() {
      return users
        .doc('ABC123')
        .update({'company': 'Stokes and Sons'})
        .then((value) => print("User Updated"))
        .catchError((error) => print("Failed to update user: $error"));
    }
    

    您可以在 Cloud Firestore 中获取有关 Cloud FirestoreHow to update 数据的更多信息。 只需在谷歌上搜索

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 2020-01-14
        • 2021-03-12
        • 2021-01-25
        • 1970-01-01
        • 2021-04-14
        • 2019-01-09
        • 2020-08-05
        • 1970-01-01
        相关资源
        最近更新 更多