- Reference >
- Operators >
- Update Operators >
- Array Update Operators >
- $pull
$pull¶
-
$pull¶ The
$pulloperator removes all instances of a value from an existing array, as in the following prototype:$pullremoves items from the array in the field namedfieldthat match the query in the$pullstatement.If a value (i.e.
<value>) exists multiple times in an array,$pullwill remove all instances of the value.Example
Given the following document in the
cpuinfocollection:The following operation will remove the
msrvalue from theflagsarray:Example
Given the following document in the
profilescollection:The following operation will remove all occurrences of
7from thevotesarray.Therefore, the
votesarray would resemble the following:Conversely, the following operation will remove all items from the array that are larger than
6:Therefore, the
votesarray would resemble the following: