This version of the documentation is archived and no longer supported.


On this page



The following page refers to the update operator $unset. For the aggregation stage $unset, available starting in MongoDB 4.2, see $unset.


The $unset operator deletes a particular field. Consider the following syntax:

{ $unset: { <field1>: "", ... } }

The specified value in the $unset expression (i.e. "") does not impact the operation.

To specify a <field> in an embedded document or in an array, use dot notation.


If the field does not exist, then $unset does nothing (i.e. no operation).

When used with $ to match an array element, $unset replaces the matching element with null rather than removing the matching element from the array. This behavior keeps consistent the array size and element positions.


The following update() operation uses the $unset operator to remove the fields quantity and instock from the first document in the products collection where the field sku has a value of unknown.

   { sku: "unknown" },
   { $unset: { quantity: "", instock: "" } }