Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.queryUpdateQueryall

all

open val <E> Field<T, Collection<E>>.all: Field<T, E>

The all positional operator: selects all elements of an array.

This operator is used to declare an update that applies to all items of an array.

Example

class User(
    val name: String,
    val pets: List<Pet>,
)

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

users.updateMany {
    User::pets.all / Pet::age inc 1
}

External resources

open val <E> KProperty1<T, Collection<E>>.all: Field<T, E>

The all positional operator: selects all elements of an array.

This operator is used to declare an update that applies to all items of an array.

Example

class User(
    val name: String,
    val pets: List<Pet>,
)

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

users.updateMany {
    User::pets.all / Pet::age inc 1
}

External resources