[Vuejs]-How to add an object to an array that already contains objects without rewriting data in firestore?

0👍

To add an object to an array that already contains objects in Firestore without rewriting the entire array, you can use the arrayUnion() or arrayRemove() method.

Here is an example of using arrayUnion() to add an object to an array:

// Add a new object to the 'items' array
firestore.collection("collectionName").doc("docId").update({
items: firebase.firestore.FieldValue.arrayUnion({ name: "itemName", 
quantity: 2 })
});

Leave a comment