does anyone know how to push data to array in firebase without overwriting? I use this solution, but unfortunately it overwrites the existing data:
db.collection('Goals').doc('Aqd8aP8uLSvuAgsMs5aW').update({"nested": ['12','14']})
If the items in the array are unique, you can use array union:
db.collection('Goals').doc('Aqd8aP8uLSvuAgsMs5aW')
.update({"nested": firebase.firestore.FieldValue.arrayUnion(['12','14'])})
If the items in the array are not unique, there is no way to do this with a single statement, and you will need to:
Also see:
According to the documentation https://firebase.google.com/docs/firestore/manage-data/add-data you should merge data:
If the document does not exist, it will be created. If the document does exist, its contents will be overwritten with the newly provided data, unless you specify that the data should be merged into the existing document, as follows:
db.collection('Goals').doc('Aqd8aP8uLSvuAgsMs5aW').set({"nested": ['12','14']}, { merge: true });