exclude
Excludes a field from the output document.
If you only want to exclude fields, use the $unset stage instead.
This function is implemented using the $$REMOVE special variable.
Example
class User(
val _id: ObjectId,
val name: String,
val age: Int,
)
class UserIsAdult(
val _id: ObjectId,
val name: String,
val isAdult: Boolean,
)
users.aggregate()
.set {
UserIsAdult::isAdult set (User::age gte 18)
exclude(User::age)
}Content copied to clipboard