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

$unset

$unset

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

db.collection.update( { field: value1 }, { $unset: { field1: "" } } );

The above example deletes field1 in collection from documents where field has a value of value1. 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.