- Reference >
- Operators >
- Update Operators >
- Array Update Operators >
- $addToSet
$addToSet¶
-
$addToSet¶ The
$addToSetoperator adds a value to an array only if the value is not in the array already. If the value is in the array,$addToSetreturns without modifying the array. Consider the following example:Here,
$addToSetappends<addition>to the array stored in<field>that includes the element<value>, only if<addition>is not already a member of this array.
See also