insertOne

abstract suspend fun insertOne(document: TDocument): InsertOneResult

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

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

Parameters

document

the document to insert

Throws

com.mongodb.MongoWriteException
com.mongodb.MongoWriteConcernException
com.mongodb.MongoException

abstract suspend fun insertOne(document: TDocument, options: InsertOneOptions): InsertOneResult

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

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

Since

3.2

Parameters

document

the document to insert

options

the options to apply to the operation

Throws

com.mongodb.MongoWriteException
com.mongodb.MongoWriteConcernException
com.mongodb.MongoCommandException
com.mongodb.MongoException

abstract suspend fun insertOne(clientSession: ClientSession, document: TDocument): InsertOneResult

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

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

Since

3.6

Parameters

clientSession

the client session with which to associate this operation

document

the document to insert

Throws

com.mongodb.MongoWriteException
com.mongodb.MongoWriteConcernException
com.mongodb.MongoException

abstract suspend fun insertOne(    clientSession: ClientSession,     document: TDocument,     options: InsertOneOptions): InsertOneResult

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

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

Since

3.6

Parameters

clientSession

the client session with which to associate this operation

document

the document to insert

options

the options to apply to the operation

Throws

com.mongodb.MongoWriteException
com.mongodb.MongoWriteConcernException
com.mongodb.MongoCommandException
com.mongodb.MongoException