updateMany

fun MongoCollection<Document>.updateMany(flow: Flow<Document>, filter: Bson, concurrency: Int = 1, groupStrategy: GroupStrategy = GroupStrategy.TimeWindow(10, 500.milliseconds)): Flow<UpdateResult>

Updates many documents in a MongoDB collection using a flow of update documents, a filter, and batching by the provided chunkStrategy.

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.updateMany(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.

groupStrategy

The strategy for chunking the update documents. Defaults to ChunkStrategy.TimeWindow(10, 500.milliseconds).