Skip to content

MongoDB driver for Kotlin (synchronous)opensavvy.ktmongo.syncJvmMongoCollection

JvmMongoCollection

Implementation of MongoCollection based on MongoDB's MongoCollection.

To access the inner iterable, see asKotlinClient.

To convert an existing MongoDB iterable into an instance of this class, see asKtMongo.

Properties

context

@LowLevelApi
open override val context: JvmBsonContext

Functions

aggregate

Start an aggregation pipeline.

asKotlinClient

@LowLevelApi
fun asKotlinClient(): MongoCollection<Document>

bulkWrite

open override fun bulkWrite(options: BulkWriteOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, operations: BulkWrite<Document>.() -> Unit)

Performs multiple update operations in a single request.

count

open override fun count(): Long

Counts how many documents exist in the collection.

open override fun count(options: CountOptions<Document>.() -> Unit, predicate: FilterQuery<Document>.() -> Unit): Long

Counts how many documents match predicate in the collection.

countEstimated

open override fun countEstimated(): Long

Counts all documents in the collection.

deleteMany

open override fun deleteMany(options: DeleteManyOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit)

Deletes all documents that match filter.

deleteOne

open override fun deleteOne(options: DeleteOneOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit)

Deletes the first document found that matches filter.

drop

open override fun drop(options: DropOptions<Document>.() -> Unit)

Removes an entire collection from the database.

filter

Returns a filtered collection that only contains the elements that match filter.

find

open override fun find(): JvmMongoIterable<Document>

Finds all documents in this collection.

open override fun find(options: FindOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit): JvmMongoIterable<Document>

Finds all documents in this collection that satisfy filter.

findOne

open fun findOne(options: FindOptions<Document>.() -> Unit = {}, filter: FilterQuery<Document>.() -> Unit): Document?

Finds a document in this collection that satisfies filter.

findOneAndUpdate

open override fun findOneAndUpdate(options: UpdateOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, update: UpdateQuery<Document>.() -> Unit): Document?

Updates one element that matches filter according to update and returns it, atomically.

insertMany

open override fun insertMany(documents: Iterable<Document>, options: InsertManyOptions<Document>.() -> Unit)

Inserts multiple documents in a single operation.

open fun insertMany(vararg documents: Document, options: InsertManyOptions<Document>.() -> Unit = {})

Inserts multiple documents in a single operation.

insertOne

open override fun insertOne(document: Document, options: InsertOneOptions<Document>.() -> Unit)

Inserts a document.

toString

open override fun toString(): String

updateMany

open override fun updateMany(options: UpdateOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, update: UpdateQuery<Document>.() -> Unit)

Updates all documents that match filter according to update.

updateManyWithPipeline

open override fun updateManyWithPipeline(options: UpdateOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, update: UpdateWithPipelineQuery<Document>.() -> Unit)

Updates all documents that match filter according to the update pipeline.

updateOne

open override fun updateOne(options: UpdateOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, update: UpdateQuery<Document>.() -> Unit)

Updates a single document that matches filter according to update.

updateOneWithPipeline

open override fun updateOneWithPipeline(options: UpdateOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, update: UpdateWithPipelineQuery<Document>.() -> Unit)

Updates a single document that matches filter according to the update pipeline.

upsertOne

open override fun upsertOne(options: UpdateOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, update: UpsertQuery<Document>.() -> Unit)

Updates a single document that matches filter according to update.

upsertOneWithPipeline

open override fun upsertOneWithPipeline(options: UpdateOptions<Document>.() -> Unit, filter: FilterQuery<Document>.() -> Unit, update: UpdateWithPipelineQuery<Document>.() -> Unit)

Updates a single document that matches filter according to the update pipeline.