exists

open fun exists(options: CountOptions<Document>.() -> Unit = {}, predicate: FilterQuery<Document>.() -> Unit): Boolean(source)

Tests if there exists a document that matches predicate in the collection.

This method is a convenience function for calling count with a limit of 1.

Example

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

collection.exists {
User::name eq "foo"
User::age eq 10
}