unset
Removes fields from documents.
Example
We can use this stage to migrate from a schema to a newer schema.
class User(
val name: String,
val age: Int?, // deprecated
val birthYear: Int?, // new field
)
val currentYear = 2025
users.updateManyWithPipeline {
set {
User::birthYear set (of(currentYear) - of(age))
}
unset {
exclude(User::age)
}
}
Content copied to clipboard