FindOperations¶
interface FindOperations<Document : Any> : BaseOperations
The different MongoDB operations related to finding documents.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract val context: BsonContext
The full BSON configuration, used by the DSL to generate queries.
For more information, see 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
findOne: When only one result is expected.
findOne¶
open suspend 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, an 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
find: When multiple results are expected.