- Reference >
- Operators >
- Aggregation Pipeline Stages >
- $unset (aggregation)
$unset (aggregation)¶
On this page
Definition¶
Disambiguation
The following page refers to the aggregation stage
$unset
. For the update operator $unset
, see
$unset
.
-
$unset
¶ New in version 4.2.
Removes/excludes fields from documents.
Considerations¶
Embedded Fields¶
To remove/exclude a field or fields within an embedded document, you can use the dot notation, as in:
or
Examples¶
Create a sample books
collection with the following documents:
Remove a Single Field¶
The following example removes the top-level field copies
:
Alternatively, you can also use the following syntax:
Either operation returns the following documents: