FindOperations¶
interface FindOperations<Document : Any> : BaseOperations
Interface grouping MongoDB operations allowing to search for information.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract val context: BsonContext
Functions¶
find¶
abstract fun find(): MongoIterable<Document>
abstract fun find(options: FindOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit): MongoIterable<Document>
Finds all documents in this collection that satisfy filter.
If multiple predicates are specified, an and operator is implied.
Example¶
class User(
val name: String,
val age: Int,
)
collection.find {
User::name eq "foo"
User::age eq 10
}
External resources¶
See also
FindOperations.findOne: When only one result is expected.
findOne¶
open fun findOne(options: FindOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit): Document?
Finds a document in this collection that satisfies filter.
If multiple predicates are specified, and 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.