mod

open fun Field<T, Number>.mod(divisor: Long, remainder: Long)(source)
open fun KProperty1<T, Number>.mod(divisor: Long, remainder: Long)(source)
open fun Field<T, Number>.mod(divisor: Int, remainder: Int)(source)
open fun KProperty1<T, Number>.mod(divisor: Int, remainder: Int)(source)

Selects documents where the value of the field divided by divisor has the specified remainder.

If the value of the field is a floating-point number, it is rounded towards zero before the operation.

Example

To find all users with an odd score:

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

collection.find {
User::age.mod(2, 1)
}

This request returns elements where age % 2 == 1.

External resources