0

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

1 Answer 1

1

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)
})
Sign up to request clarification or add additional context in comments.

1 Comment

ailoviu su moch c:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.