maxTime

open fun maxTime(timeout: Duration)(source)

Specifies a maximum amount of time for processing the request.

MongoDB does not support sub-millisecond timeouts, so any non-zero timeout less than 1 millisecond is treated as 1 full millisecond.

0 disables the timeout.

Support

  • The official Kotlin driver does not support this option in insert operations. See JAVA-6301.

Example

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

collection.count(
options = { maxTime(10.seconds) }
) {
User::age eq 10
}