$unset¶
-
$unset
¶ The
$unset
operator deletes a particular field. Consider the following example:The above example deletes
field1
incollection
from documents wherefield
has a value ofvalue1
. The value of the field in the$unset
statement (i.e.""
above) does not impact the operation.If documents match the initial query (e.g.
{ field: value1 }
above) but do not have the field specified in the$unset
operation (e.g.field1
), then the statement has no effect on the document.