MongoDB driver for Kotlin (coroutines) • opensavvy.ktmongo.coroutines.operations • FindOperations • findOne
findOne¶
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¶
FindOperations.find
When multiple results are expected.