- Reference >
- Operators >
- Update Operators >
- Field Update Operators >
- $unset
$unset¶
-
$unset
¶ The
$unset
operator deletes a particular field. The specified value in the$unset
expression (i.e.""
below) does not impact the operation. If the field does not exist, then$unset
has no effect. Consider the following syntax:For example, the following
update()
operation uses the$unset
operator to remove the fieldsquantity
andinstock
from the first document found in theproducts
collection where the fieldsku
has a value ofunknown
.To remove the fields from all documents in the collection where the field
sku
has a value ofunknown
, specify themulti: true
option in theupdate()
method, as in the following example: