- Reference >
- Operators >
- Update Operators >
- Field Update Operators >
- $inc
$inc¶
On this page
Definition¶
-
$inc¶ The
$incoperator increments a field by a specified value and has the following form:To specify a
<field>in an embedded document or in an array, use dot notation.
Behavior¶
The $inc operator accepts positive and negative values.
If the field does not exist, $inc creates the field and sets
the field to the specified value.
Use of the $inc operator on a field with a null value will
generate an error.
$inc is an atomic operation within a single document.