Firestore's FieldValue.increment(someValue) is working properly with other fields but not with map.
I am trying to increment the value of a property in a map. I have a document named user. It has a map points:{id:123, total:100}. I want to update the value of total in map points.
firestore.collection('users').doc('user').update({
"name": "atul",
"points": { "total": firestore.FieldValue.increment(50) }
})
Instead of incrementing the total value to 150, its value becomes 100.
You'll need to call out the full path of the field to increment, not bury it inside an object. The full path of the field involves using . as a separator between the names of each field:
firestore.doc(...).update({
"points.total": firestore.FieldValue.increment(50)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With