field

Converts a Kotlin property into a Field.

The KtMongo DSL is built on top of the Field interface, which represents a specific field in a document (possibly nested).

To help with writing requests, we provide utilities to use Kotlin property references as well:

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

println(User::name) // KProperty1…
println(User::name.field) // Field 'name'

Most functions of the DSL have an overload that accepts a KProperty1 and calls field before calling the real operator implementation.