Package-level declarations

Types

Link copied to clipboard
typealias CoroutineAggregatePublisher<T> = AggregateFlow<T>
Link copied to clipboard
typealias CoroutineChangeStreamPublisher<T> = ChangeStreamFlow<T>
Link copied to clipboard
typealias CoroutineClient = MongoClient
Link copied to clipboard
typealias CoroutineCollection<T> = MongoCollection<T>
Link copied to clipboard
typealias CoroutineDatabase = MongoDatabase
Link copied to clipboard
typealias CoroutineDistinctPublisher<T> = DistinctFlow<T>
Link copied to clipboard
typealias CoroutineFindPublisher<T> = FindFlow<T>
Link copied to clipboard
typealias CoroutineListCollectionsPublisher<T> = ListCollectionsFlow<T>
Link copied to clipboard
typealias CoroutineListIndexesPublisher<T> = ListIndexesFlow<T>
Link copied to clipboard
object KMongo

Creates MongoClient instances of the official MongoDB Kotlin coroutine driver, configured with the KMongo object mapping.

Properties

Link copied to clipboard
val MongoClient.coroutine: MongoClient

KMongo 4/5: converted a reactive streams client to a coroutine client. The client is already a coroutine client.

val <T : Any> MongoCollection<T>.coroutine: MongoCollection<T>

KMongo 4/5: converted a reactive streams collection. The collection is already a coroutine collection.

val MongoDatabase.coroutine: MongoDatabase

KMongo 4/5: converted a reactive streams database. The database is already a coroutine database.

Functions

Link copied to clipboard
suspend fun ClientSession.abortTransactionAndAwait()

KMongo 4/5 coroutine extension of the reactive streams ClientSession.

Link copied to clipboard
inline fun <TResult : Any> MongoCollection<*>.aggregate(vararg pipeline: String): AggregateFlow<TResult>
inline fun <TResult : Any> MongoCollection<*>.aggregate(vararg pipeline: Bson): AggregateFlow<TResult>
inline fun <TResult : Any> MongoCollection<*>.aggregate(clientSession: ClientSession, vararg pipeline: String): AggregateFlow<TResult>
inline fun <TResult : Any> MongoCollection<*>.aggregate(clientSession: ClientSession, vararg pipeline: Bson): AggregateFlow<TResult>

Aggregates documents according to the specified aggregation pipeline.

Link copied to clipboard
fun <T : Any> FindFlow<T>.ascendingSort(vararg properties: KProperty<*>): FindFlow<T>

Sets the sort criteria with specified ascending properties to apply to the query.

Link copied to clipboard
inline suspend fun <T : Any> MongoCollection<T>.bulkWrite(vararg requests: WriteModel<T>, options: BulkWriteOptions = BulkWriteOptions()): BulkWriteResult
inline suspend fun <T : Any> MongoCollection<T>.bulkWrite(vararg requests: String, options: BulkWriteOptions = BulkWriteOptions()): BulkWriteResult
inline suspend fun <T : Any> MongoCollection<T>.bulkWrite(clientSession: ClientSession, vararg requests: WriteModel<T>, options: BulkWriteOptions = BulkWriteOptions()): BulkWriteResult
inline suspend fun <T : Any> MongoCollection<T>.bulkWrite(clientSession: ClientSession, vararg requests: String, options: BulkWriteOptions = BulkWriteOptions()): BulkWriteResult

Executes a mix of inserts, updates, replaces, and deletes.

Link copied to clipboard
suspend fun ClientSession.commitTransactionAndAwait()

KMongo 4/5 coroutine extension of the reactive streams ClientSession.

Link copied to clipboard
suspend fun <T> Flow<T>.consumeEach(action: suspend (T) -> Unit)

KMongo 4/5 CoroutinePublisher.consumeEach: iterates over all elements.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.countDocuments(filter: String, options: CountOptions = CountOptions()): Long
suspend fun <T : Any> MongoCollection<T>.countDocuments(clientSession: ClientSession, filter: String, options: CountOptions = CountOptions()): Long

Counts the number of documents in the collection according to the given options.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.createIndex(keys: String, indexOptions: IndexOptions = IndexOptions()): String
suspend fun <T : Any> MongoCollection<T>.createIndex(clientSession: ClientSession, keys: String, indexOptions: IndexOptions = IndexOptions()): String

Create an index with the given keys and options.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.deleteMany(filter: String, options: DeleteOptions = DeleteOptions()): DeleteResult
suspend fun <T : Any> MongoCollection<T>.deleteMany(vararg filters: Bson?, options: DeleteOptions = DeleteOptions()): DeleteResult
suspend fun <T : Any> MongoCollection<T>.deleteMany(clientSession: ClientSession, filter: String, options: DeleteOptions = DeleteOptions()): DeleteResult
suspend fun <T : Any> MongoCollection<T>.deleteMany(clientSession: ClientSession, vararg filters: Bson?, options: DeleteOptions = DeleteOptions()): DeleteResult

Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.deleteOne(filter: String, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult
suspend fun <T : Any> MongoCollection<T>.deleteOne(vararg filters: Bson?, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult
suspend fun <T : Any> MongoCollection<T>.deleteOne(clientSession: ClientSession, filter: String, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult
suspend fun <T : Any> MongoCollection<T>.deleteOne(clientSession: ClientSession, vararg filters: Bson?, deleteOptions: DeleteOptions = DeleteOptions()): DeleteResult

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.deleteOneById(id: Any): DeleteResult
suspend fun <T : Any> MongoCollection<T>.deleteOneById(clientSession: ClientSession, id: Any): DeleteResult

Removes at most one document from the id parameter. If no documents match, the collection is not modified.

Link copied to clipboard
fun <T : Any> FindFlow<T>.descendingSort(vararg properties: KProperty<*>): FindFlow<T>

Sets the sort criteria with specified descending properties to apply to the query.

Link copied to clipboard
inline fun <TResult : Any> MongoCollection<*>.distinct(fieldName: String, filter: String = KMongoUtil.EMPTY_JSON): DistinctFlow<TResult>
inline fun <TResult : Any> MongoCollection<*>.distinct(clientSession: ClientSession, fieldName: String, filter: String = KMongoUtil.EMPTY_JSON): DistinctFlow<TResult>

Gets the distinct values of the specified field name.

inline fun <T : Any, TResult : Any> MongoCollection<T>.distinct(field: KProperty1<T, TResult?>, filter: Bson = EMPTY_BSON): DistinctFlow<TResult>
inline fun <T : Any, TResult : Any> MongoCollection<T>.distinct(clientSession: ClientSession, field: KProperty1<T, TResult?>, filter: Bson = EMPTY_BSON): DistinctFlow<TResult>

Gets the distinct values of the specified field.

Link copied to clipboard
inline suspend fun <T : Any> MongoDatabase.dropCollection()

Drops the default collection of T (see getCollection).

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.dropIndex(keys: String)
suspend fun <T : Any> MongoCollection<T>.dropIndex(clientSession: ClientSession, keys: String)

Drops the index given the keys used to create it.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.dropIndexOfKeys(json: String)
suspend fun <T : Any> MongoCollection<T>.dropIndexOfKeys(clientSession: ClientSession, json: String)

Drops the index given the keys used to create it.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.ensureIndex(keys: String, indexOptions: IndexOptions = IndexOptions()): String
suspend fun <T : Any> MongoCollection<T>.ensureIndex(keys: Bson, indexOptions: IndexOptions = IndexOptions()): String
suspend fun <T : Any> MongoCollection<T>.ensureIndex(clientSession: ClientSession, keys: String, indexOptions: IndexOptions = IndexOptions()): String
suspend fun <T : Any> MongoCollection<T>.ensureIndex(clientSession: ClientSession, keys: Bson, indexOptions: IndexOptions = IndexOptions()): String

Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

suspend fun <T : Any> MongoCollection<T>.ensureIndex(vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): String
suspend fun <T : Any> MongoCollection<T>.ensureIndex(clientSession: ClientSession, vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): String

Create an ascending index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.ensureUniqueIndex(vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): String
suspend fun <T : Any> MongoCollection<T>.ensureUniqueIndex(clientSession: ClientSession, vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): String

Create an IndexOptions.unique index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Link copied to clipboard
fun <T : Any> DistinctFlow<T>.filter(filter: String): DistinctFlow<T>
fun <T : Any> FindFlow<T>.filter(filter: String): FindFlow<T>

Sets the query filter to apply to the query.

Link copied to clipboard
fun <T : Any> MongoCollection<T>.find(filter: String = KMongoUtil.EMPTY_JSON): FindFlow<T>
fun <T : Any> MongoCollection<T>.find(vararg filters: Bson?): FindFlow<T>
fun <T : Any> MongoCollection<T>.find(clientSession: ClientSession, filter: String = KMongoUtil.EMPTY_JSON): FindFlow<T>
fun <T : Any> MongoCollection<T>.find(clientSession: ClientSession, vararg filters: Bson?): FindFlow<T>

Finds all documents in the collection.

Link copied to clipboard
inline fun <T : Any> MongoCollection<*>.findAndCast(filter: Bson = EMPTY_BSON): FindFlow<T>
inline fun <T : Any> MongoCollection<*>.findAndCast(clientSession: ClientSession, filter: Bson): FindFlow<T>

KMongo 4/5 CoroutineCollection.findAndCast: finds all documents in the collection, mapped to T.

Link copied to clipboard
inline suspend fun <T : Any> MongoCollection<T>.findOne(filters: () -> Bson): T?
suspend fun <T : Any> MongoCollection<T>.findOne(filter: String = KMongoUtil.EMPTY_JSON): T?
suspend fun <T : Any> MongoCollection<T>.findOne(filter: Bson): T?
inline suspend fun <T : Any> MongoCollection<T>.findOne(clientSession: ClientSession, filters: () -> Bson): T?
suspend fun <T : Any> MongoCollection<T>.findOne(clientSession: ClientSession, filter: String = KMongoUtil.EMPTY_JSON): T?
suspend fun <T : Any> MongoCollection<T>.findOne(clientSession: ClientSession, filter: Bson): T?

Finds the first document that match the filter in the collection.

suspend fun <T : Any> MongoCollection<T>.findOne(vararg filters: Bson?): T?
suspend fun <T : Any> MongoCollection<T>.findOne(clientSession: ClientSession, vararg filters: Bson?): T?

Finds the first document that match the filters in the collection.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.findOneAndDelete(filter: String, options: FindOneAndDeleteOptions = FindOneAndDeleteOptions()): T?
suspend fun <T : Any> MongoCollection<T>.findOneAndDelete(clientSession: ClientSession, filter: String, options: FindOneAndDeleteOptions = FindOneAndDeleteOptions()): T?

Atomically find a document and remove it.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.findOneAndReplace(filter: String, replacement: T, options: FindOneAndReplaceOptions = FindOneAndReplaceOptions()): T?
suspend fun <T : Any> MongoCollection<T>.findOneAndReplace(clientSession: ClientSession, filter: String, replacement: T, options: FindOneAndReplaceOptions = FindOneAndReplaceOptions()): T?

Atomically find a document and replace it.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.findOneAndUpdate(filter: String, update: String, options: FindOneAndUpdateOptions = FindOneAndUpdateOptions()): T?
suspend fun <T : Any> MongoCollection<T>.findOneAndUpdate(clientSession: ClientSession, filter: String, update: String, options: FindOneAndUpdateOptions = FindOneAndUpdateOptions()): T?

Atomically find a document and update it.

suspend fun <T : Any> MongoCollection<T>.findOneAndUpdate(filter: Bson, update: T, options: FindOneAndUpdateOptions = FindOneAndUpdateOptions()): T?
suspend fun <T : Any> MongoCollection<T>.findOneAndUpdate(clientSession: ClientSession, filter: Bson, update: T, options: FindOneAndUpdateOptions = FindOneAndUpdateOptions()): T?

Atomically find a document and update it with the not null properties of update.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.findOneById(id: Any): T?
suspend fun <T : Any> MongoCollection<T>.findOneById(clientSession: ClientSession, id: Any): T?

Finds the document that match the id parameter.

suspend fun <T : Any> MongoCollection<T>.findOneById(id: Any, clientSession: ClientSession): T?

Finds the document with the specified id.

Link copied to clipboard
suspend fun <T : Any> AggregateFlow<T>.first(): T?

KMongo 4/5 CoroutineAggregatePublisher.first returned null if there is no result.

suspend fun <T : Any> DistinctFlow<T>.first(): T?

KMongo 4/5 CoroutineDistinctPublisher.first returned null if there is no result.

suspend fun <T : Any> FindFlow<T>.first(): T?

KMongo 4/5 CoroutineFindPublisher.first returned null if there is no result (kotlinx.coroutines.flow.first throws a NoSuchElementException).

Link copied to clipboard
inline fun <T : Any> MongoDatabase.getCollection(): MongoCollection<T>
inline fun <T : Any> MongoDatabase.getCollection(collectionName: String): MongoCollection<T>

Gets a collection.

Link copied to clipboard
inline fun <T : Any> MongoDatabase.getCollectionOfName(collectionName: String): MongoCollection<T>

Gets a collection.

Link copied to clipboard
inline suspend fun <T : Any> MongoCollection<T>.insertOne(document: String, options: InsertOneOptions = InsertOneOptions()): InsertOneResult
inline suspend fun <T : Any> MongoCollection<T>.insertOne(clientSession: ClientSession, document: String, options: InsertOneOptions = InsertOneOptions()): InsertOneResult

Inserts the provided document. If the document is missing an identifier, the driver should generate one.

Link copied to clipboard
inline fun <TResult : Any> MongoCollection<*>.listIndexes(): ListIndexesFlow<TResult>
inline fun <TResult : Any> MongoCollection<*>.listIndexes(clientSession: ClientSession): ListIndexesFlow<TResult>

Get all the indexes in this collection.

Link copied to clipboard
inline fun <TResult : Any> MongoCollection<*>.listTypedIndexes(): ListIndexesFlow<TResult>
inline fun <TResult : Any> MongoCollection<*>.listTypedIndexes(clientSession: ClientSession): ListIndexesFlow<TResult>

Get all the indexes in this collection.

Link copied to clipboard
suspend fun <FROM : Any> lookup(from: MongoCollection<FROM>, localField: KProperty1<out Any, Any?>, foreignField: KProperty1<FROM, Any?>, newAs: KProperty1<out Any, Any?>): Bson

Creates a $lookup pipeline stage for the specified filter (Typesafe version)

Link copied to clipboard
fun <T : Any> FindFlow<T>.projection(projection: String): FindFlow<T>
fun <T : Any> FindFlow<T>.projection(vararg projections: KProperty<*>): FindFlow<T>

Sets a document describing the fields to return for all matching documents.

inline fun <T : Any, F> MongoCollection<T>.projection(property: KProperty<F>, query: Bson = EMPTY_BSON, options: (FindFlow<SingleProjection<F>>) -> FindFlow<SingleProjection<F>> = { it }): Flow<F?>
inline fun <T : Any, F> MongoCollection<T>.projection(clientSession: ClientSession, property: KProperty<F>, query: Bson = EMPTY_BSON, options: (FindFlow<SingleProjection<F>>) -> FindFlow<SingleProjection<F>> = { it }): Flow<F?>

Returns the specified field for all matching documents.

inline fun <T : Any, F1, F2> MongoCollection<T>.projection(property1: KProperty<F1>, property2: KProperty<F2>, query: Bson = EMPTY_BSON, options: (FindFlow<PairProjection<F1, F2>>) -> FindFlow<PairProjection<F1, F2>> = { it }): Flow<Pair<F1?, F2?>>
inline fun <T : Any, F1, F2> MongoCollection<T>.projection(clientSession: ClientSession, property1: KProperty<F1>, property2: KProperty<F2>, query: Bson = EMPTY_BSON, options: (FindFlow<PairProjection<F1, F2>>) -> FindFlow<PairProjection<F1, F2>> = { it }): Flow<Pair<F1?, F2?>>

Returns the specified two fields for all matching documents.

inline fun <T : Any, F1, F2, F3> MongoCollection<T>.projection(property1: KProperty<F1>, property2: KProperty<F2>, property3: KProperty<F3>, query: Bson = EMPTY_BSON, options: (FindFlow<TripleProjection<F1, F2, F3>>) -> FindFlow<TripleProjection<F1, F2, F3>> = { it }): Flow<Triple<F1?, F2?, F3?>>
inline fun <T : Any, F1, F2, F3> MongoCollection<T>.projection(clientSession: ClientSession, property1: KProperty<F1>, property2: KProperty<F2>, property3: KProperty<F3>, query: Bson = EMPTY_BSON, options: (FindFlow<TripleProjection<F1, F2, F3>>) -> FindFlow<TripleProjection<F1, F2, F3>> = { it }): Flow<Triple<F1?, F2?, F3?>>

Returns the specified three fields for all matching documents.

Link copied to clipboard
inline suspend fun <T : Any> MongoCollection<T>.replaceOne(replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult
inline suspend fun <T : Any> MongoCollection<T>.replaceOne(clientSession: ClientSession, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.replaceOne(filter: String, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.replaceOne(clientSession: ClientSession, filter: String, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult

Replace a document in the collection according to the specified arguments.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.replaceOneById(id: Any, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.replaceOneById(clientSession: ClientSession, id: Any, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult

Replace a document in the collection according to the specified arguments.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.replaceOneWithFilter(filter: Bson, replacement: T, replaceOptions: ReplaceOptions = ReplaceOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.replaceOneWithFilter(clientSession: ClientSession, filter: Bson, replacement: T, replaceOptions: ReplaceOptions = ReplaceOptions()): UpdateResult

Replace a document in the collection according to the specified arguments. Same than MongoCollection.replaceOne but ensure that any _id present in replacement is removed to avoid MongoWriteException such as: "After applying the update, the (immutable) field '_id' was found to have been altered to _id"

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.replaceOneWithoutId(filter: Bson, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.replaceOneWithoutId(clientSession: ClientSession, filter: Bson, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult

Replaces a document in the collection according to the specified arguments (the _id of the replacement is ignored).

Link copied to clipboard
inline suspend fun <TResult : Any> MongoDatabase.runCommand(command: String): TResult
inline suspend fun <TResult : Any> MongoDatabase.runCommand(clientSession: ClientSession, command: String): TResult
inline suspend fun <TResult : Any> MongoDatabase.runCommand(command: String, readPreference: ReadPreference): TResult
inline suspend fun <TResult : Any> MongoDatabase.runCommand(clientSession: ClientSession, command: String, readPreference: ReadPreference): TResult

Executes the given command in the context of the current database with the given read preference.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.save(document: T): UpdateResult?
suspend fun <T : Any> MongoCollection<T>.save(clientSession: ClientSession, document: T): UpdateResult?

Save the document. If the document has no id field, or if the document has a null id value, insert the document. Otherwise, call replaceOneById with upsert true.

Link copied to clipboard
fun <T : Any> FindFlow<T>.sort(sort: String): FindFlow<T>

Sets the sort criteria to apply to the query.

Link copied to clipboard
fun <T : Any> AggregateFlow<T>.toFlow(): Flow<T>
fun <T : Any> FindFlow<T>.toFlow(): Flow<T>

KMongo 4/5: returned the publisher as a Flow. Driver flows are already Flows.

Link copied to clipboard
suspend fun <T : Any> AggregateFlow<T>.toList(): List<T>
suspend fun <T : Any> DistinctFlow<T>.toList(): List<T>
suspend fun <T : Any> FindFlow<T>.toList(): List<T>
suspend fun <T : Any> ListCollectionsFlow<T>.toList(): List<T>
suspend fun <T : Any> ListIndexesFlow<T>.toList(): List<T>

Returns all the results as a list (KMongo 4/5 publishers provided a toList() member).

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.updateMany(filter: String, update: String, updateOptions: UpdateOptions = UpdateOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateMany(filter: Bson, vararg updates: SetTo<*>, updateOptions: UpdateOptions = UpdateOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateMany(clientSession: ClientSession, filter: String, update: String, updateOptions: UpdateOptions = UpdateOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateMany(clientSession: ClientSession, filter: Bson, vararg updates: SetTo<*>, updateOptions: UpdateOptions = UpdateOptions()): UpdateResult

Update all documents in the collection according to the specified arguments.

Link copied to clipboard
inline suspend fun <T : Any> MongoCollection<T>.updateOne(target: T, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(filter: String, update: String, options: UpdateOptions = UpdateOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(filter: Bson, vararg updates: SetTo<*>, updateOptions: UpdateOptions = UpdateOptions()): UpdateResult
inline suspend fun <T : Any> MongoCollection<T>.updateOne(clientSession: ClientSession, target: T, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(clientSession: ClientSession, filter: String, update: String, options: UpdateOptions = UpdateOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(clientSession: ClientSession, filter: Bson, vararg updates: SetTo<*>, updateOptions: UpdateOptions = UpdateOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(filter: String, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(filter: Bson, target: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(clientSession: ClientSession, filter: String, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOne(clientSession: ClientSession, filter: Bson, target: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult

Update a single document in the collection according to the specified arguments.

Link copied to clipboard
suspend fun <T : Any> MongoCollection<T>.updateOneById(id: Any, vararg updates: SetTo<*>, options: UpdateOptions = UpdateOptions()): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOneById(id: Any, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult
suspend fun <T : Any> MongoCollection<T>.updateOneById(clientSession: ClientSession, id: Any, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult

Update a single document in the collection according to the specified arguments.

Link copied to clipboard
fun <T : Any> MongoCollection<T>.watchIndefinitely(pipeline: List<Bson> = emptyList(), fullDocument: FullDocument = FullDocument.DEFAULT, retryDelay: Duration = 1.seconds, maxRetryDelay: Duration = 1.minutes, onError: suspend (Throwable) -> Unit = {}, configure: ChangeStreamFlow<T>.() -> ChangeStreamFlow<T> = { this }): Flow<ChangeStreamDocument<T>>

Watches the collection indefinitely: a change stream that survives the errors and the invalidations.

Link copied to clipboard
fun <T : Any> MongoCollection<T>.withKMongo(): MongoCollection<T>

Returns a MongoCollection with a KMongo codec.

suspend fun MongoDatabase.withKMongo(): MongoDatabase

Returns a MongoDatabase with a KMongo codec.