简体   繁体   中英

How can I update document firestore flutter

How can I update document with adding all registered users id as a field of updating document?

First of all, please don't ask easier to find solution questions, which are have answered. When you wanna ask a question here, first please search your question on google, and if you can't find anything about that, then you can ask here.

And that is code, you can update your date like this:

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

Or like this:

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"));
}

You can get more about Cloud Firestore and How to update data in cloud firestore. just search on google

Here is the official documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM