I have a Firebase Firestore database, in which I have a collection users. There is an array in the collection and in the array there is a map. In the map, there is a field qty
. I want to increment that qty
field value.
Using increment doesnt help as the qty
is inside an array index
db.collection("users").doc(checkId).update({
myCart: firebase.firestore.FieldValue.arrayUnion({
qty: firebase.firestore.FieldValue.increment(1),
}),
});
and this results to the following error:
Uncaught (in promise) FirebaseError: Function FieldValue.arrayUnion() called with invalid data. FieldValue.increment() can only be used with update() and set()