- Reference >
- Operators >
- Update Operators >
- Field Update Operators >
- $unset
$unset¶
-
$unset¶ The
$unsetoperator deletes a particular field. The specified value in the$unsetexpression (i.e.""below) does not impact the operation. If the field does not exist, then$unsethas no effect. Consider the following syntax:For example, the following
update()operation uses the$unsetoperator to remove the fieldsquantityandinstockfrom the first document found in theproductscollection where the fieldskuhas a value ofunknown.To remove the fields from all documents in the collection where the field
skuhas a value ofunknown, specify themulti: trueoption in theupdate()method, as in the following example: