Reading a blog post and the docs, I found that we can increment a value using FieldValue
but I cound't find a decrement function.
document("fitness_teams/Team_1").
updateData(["step_counter" : FieldValue.decrement(500)]) //Does not exist
To decrement a value we still need to use transactions?
There is no need for a decrement function, simply pass a negative value to the actual increment()
function:
document("fitness_teams/Team_1").
updateData(["step_counter" : FieldValue.increment(-500)])
And the value of your step_counter
field will be decremented by 500.
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