Home > Enterprise >  in firebase firestore how can I update a document without overwriting subcollections?
in firebase firestore how can I update a document without overwriting subcollections?

Time:01-30

in firebase firestore how can I update a document without overwriting subcollections? speciffically in flutter.

CodePudding user response:

Update a document won't overwrite your subcollection.

CodePudding user response:

Just set your documents fields directly:

    FirebaseFirestore.instance
          .collection(COLLECTION_NAME)
          .doc(DOCUMENT_ID)
          .set({ "FIELD_NAME": "FIELD_VALUE" });

This will not affect the document collections.

If you want to just update some fields without affect other fields, you can use update method:

 FirebaseFirestore.instance
          .collection(COLLECTION_NAME)
          .doc(DOCUMENT_ID)
          .update({ "FIELD_NAME": "FIELD_VALUE" });

For further information:

https://firebase.flutter.dev/docs/firestore/usage/

  • Related