Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.queryUpdateQuerymin

min

abstract infix fun <V : Comparable<V>> Field<T, V?>.min(value: V)

Updates the value of a field to the specified value only if the specified value is less than the current value of the field.

If the field doesn't exist, the field is set to the specified value.

Example

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

collection.updateMany {
    User::score min 10
}

External resources

open infix fun <V : Comparable<V>> KProperty1<T, V?>.min(value: V)

Updates the value of a field to the specified value only if the specified value is less than the current value of the field.

If the field doesn't exist, the field is set to the specified value.

Example

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

collection.updateMany {
    User::score min 10
}

External resources