Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.pathFielddiv

div

open operator fun <Child> div(child: Field<Type, Child>): Field<Root, Child>

Refers to child as a nested field of the current field.

Examples

class User(
    val id: Int,
    val profile: Profile,
)

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

// Refer to the name
println(User::profile / Profile::name)
// → 'profile.name'

// Refer to the age
println(User::profile / Profile::age)
// → 'profile.age'

See also

  • get Access a specific element of an array
open operator fun <Child> div(child: KProperty1<in Type & Any, Child>): Field<Root, Child>

Refers to child as a nested field of the current field.

Examples

class User(
    val id: Int,
    val profile: Profile,
)

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

// Refer to the name
println(User::profile / Profile::name)
// → 'profile.name'

// Refer to the age
println(User::profile / Profile::age)
// → 'profile.age'

See also

  • get Access a specific element of an array