bulkWrite

suspend fun bulkWrite(requests: List<WriteModel<out T>>, options: BulkWriteOptions = BulkWriteOptions()): BulkWriteResult

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

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk write. If the requests contain any UpdateManyModels or DeleteManyModels then the bulk operation will not support retryable writes.

Return

the result of the bulk write

Parameters

requests

the writes to execute

options

the options to apply to the bulk write operation

Throws

MongoBulkWriteException

if there's an exception in the bulk write operation

MongoException

if there's an exception running the operation


suspend fun bulkWrite(clientSession: ClientSession, requests: List<WriteModel<out T>>, options: BulkWriteOptions = BulkWriteOptions()): BulkWriteResult

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

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk write. If the requests contain any UpdateManyModels or DeleteManyModels then the bulk operation will not support retryable writes.

Return

the result of the bulk write

Parameters

clientSession

the client session with which to associate this operation

requests

the writes to execute

options

the options to apply to the bulk write operation

Throws

MongoBulkWriteException

if there's an exception in the bulk write operation

MongoException

if there's an exception running the operation