How can I update a document in Firebase Firestore without overwriting subcollections ?
Specifically in Flutter.
2
Update a document won’t overwrite your subcollection.
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/
Click here to cancel reply.
2
Answers
Update a document won’t overwrite your subcollection.
Just set your documents fields directly:
This will not affect the document collections.
If you want to just update some fields without affect other fields, you can use update method:
For further information:
https://firebase.flutter.dev/docs/firestore/usage/