How can I update a document in Firebase Firestore without overwriting subcollections?
Specifically in Flutter.
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:
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.