Reputation: 200
I am trying to store orders(quantity, price, date, etc), I want to store each one in different arrays inside an array called "orders", but when I send the data, instead of creating a new array, it overwrites the one that was already there
this is my code
TS
this.FireServices.collection("clientData").doc(uid).update({
orders: [this.dataForm.value]
})
The data is obtained directly from a form
Upvotes: 0
Views: 313
Reputation: 317477
If you want to add a new item to an array, you should use FieldValue.arrayUnion() to add to the existing array.
this.FireServices.collection("clientData").doc(uid).update({
orders: firestore.FieldValue.arrayUnion(this.dataForm.value)
})
Upvotes: 1