How to decrease a value using FieldValue in Firestore (SWIFT)?

后端 未结 1 1174
情深已故
情深已故 2021-01-27 16:30

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(\"fitnes         


        
相关标签:
1条回答
  • 2021-01-27 17:07

    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.

    0 讨论(0)
提交回复
热议问题