include

abstract fun include(field: Field<Document, *>)(source)
open fun include(field: KProperty1<Document, *>)(source)

Explicitly includes field.

Note that fields that aren't mentioned in the $project stage are deleted (except the _id field, which must be explicitly excluded).

Example

class User(
val name: String,
val age: Int,
)

users.aggregate()
.project {
include(User::age)
}

External resources