$unset
Removes specified fields from documents.
Syntax
{ "$unset": "<fieldName>" }
{ "$unset": ["<field1>", "<field2>", ...] }
- Accepts either a single string or an array of field names.
- To remove nested fields, specify the path (for example
"shipping.trackingNumber").
✅ Basic Example
📌 Stage
{
"$unset": "internal"
}
📥 Input
{
"product": "Phone",
"internal": true
}
📤 Output
{
"product": "Phone"
}
🧱 Deep Nested Pipeline Usage (Ecommerce)
[
{
"$unset": [
"internal",
"archived"
]
}
]
📥 Input Document
{
"name": "Shoes",
"archived": false,
"internal": true
}
📤 Output Documents
{
"name": "Shoes"
}
➕ Supported Accumulators
None for this stage
🔧 Common Operators
None