update

fun MongoCollection<Document>.update(flow: Flow<Document>, filter: Bson, concurrency: Int = 1): Flow<UpdateResult>

Updates documents in a MongoDB collection using a flow of update documents and a filter.

Return

A flow of UpdateResult objects.

Example usage:

val collection = // new MongoCollection<Document>
val filter = Filters.eq("field", "value")
val updatesFlow = flowOf(Document("\$set" to Document("field" to "newValue")))
collection.update(updatesFlow, filter).collect { result -> println("Documents updated: ${result.modifiedCount}") }

Parameters

flow

The flow of update documents.

filter

The BSON filter to apply when updating documents.

concurrency

The concurrency for this operation. Defaults to 1.