Mobile Backend Services supports the Mongo
$inc atomic increment operator.
You can use
$inc to increment (or decrement) a custom field by a specified value in a single update operation.
- The operator accepts positive and negative increment amounts
- It can only be applied to a single field per method call.
$inc is specified with the following form, where
fieldName is the name of the field to update and
value is a positive (or negative) number to increment (or decrement)
The operator must be enclosed in quotes, as shown above. The following methods support the
The following example increments the
score custom field by 10 in a CustomObjects update to a custom object called
The following example decrements the
score custom field by 20 in a Checkins update:
If you apply $inc to multiple fields in one Update call, you will get an error: