findOne

open suspend fun findOne(options: <Error class: unknown class><Document>.() -> Unit = {}, filter: <Error class: unknown class><Document>.() -> Unit): Document?(source)

Finds a document in this collection that satisfies filter.

If multiple predicates are specified, and FilterQuery.and operator is implied.

This function doesn't check that there is exactly one value in the collection. It simply returns the first matching document it finds.

Example

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

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

See also

When multiple results are expected.