insertMany

suspend fun insertMany(documents: List<T>, options: InsertManyOptions = InsertManyOptions()): InsertManyResult

Inserts one or more documents. A call to this method is equivalent to a call to the bulkWrite method

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Return

the insert many result

Parameters

documents

the documents to insert

options

the options to apply to the operation

Throws

MongoBulkWriteException

if there's an exception in the bulk write operation

MongoCommandException

if the write failed due to a specific command exception

MongoException

if the write failed due some other failure

if the documents list is null or empty, or any of the documents in the list are null


suspend fun insertMany(clientSession: ClientSession, documents: List<T>, options: InsertManyOptions = InsertManyOptions()): InsertManyResult

Inserts one or more documents. A call to this method is equivalent to a call to the bulkWrite method

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Return

the insert many result

Parameters

clientSession

the client session with which to associate this operation

documents

the documents to insert

options

the options to apply to the operation

Throws

MongoBulkWriteException

if there's an exception in the bulk write operation

MongoCommandException

if the write failed due to a specific command exception

MongoException

if the write failed due some other failure

if the documents list is null or empty, or any of the documents in the list are null