Firestore has recently launched a new feature to increment and decrement the integer values atomically.
I can increment the integer value using
For instance, FieldValue.increment(50)
But how to decrement ?
I tried using FieldValue.decrement(50)
But there is no method like decrement in FieldValue.
It's not working.
https://firebase.googleblog.com/2019/03/increment-server-side-cloud-firestore.html?linkId=65365800&m=1
Firestore now has a specific operator for this called FieldValue. increment() . By applying this operator to a field, the value of that field can be incremented (or decremented) as a single operation on the server.
To decrement the value in a field, do a negative increment. So:
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