Skip to main content

exclude

Function exclude 

Source
pub fn exclude(doc: &Value, fields: &[Value]) -> Value
Expand description

Remove specified fields from a document (the inverse of project).

Returns a copy of the document with the listed fields removed. Supports dot-notation for nested fields (e.g. “meta.logins” removes only the logins field inside meta, leaving other fields in meta intact).

If removing a nested field leaves its parent object empty, the parent object is also removed (e.g. removing “meta.logins” from { meta: { logins: 10 } } removes the entire meta key since it would be empty).

Note: fields and excludedFields are mutually exclusive — the handler validates this before calling either function.