Referring to nested documents¶
For the rest of this article, let's take the following example, in which the collection we're interested in is User
:
class User(
val name: String,
val country: Country,
val pets: List<Pet>,
)
class Country(
val id: String,
val code: String,
)
class Pet(
val id: String,
val name: String,
)
Tip
Note that the KtMongo syntax is only available within the various DSL methods offered by the library.
Top-level field¶
Referring to a non-nested field is identical with KMongo and KtMongo:
Nested field¶
Referring to nested documents is identical with both libraries:
Array items¶
Referring to an array item by index uses the get
operator: