replaceOne

abstract suspend fun replaceOne(filter: Bson, replacement: TDocument): UpdateResult

Replace a document in the collection according to the specified arguments.

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

Parameters

filter

the query filter to apply the the replace operation

replacement

the replacement document

Throws

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

abstract suspend fun replaceOne(    filter: Bson,     replacement: TDocument,     options: ReplaceOptions): UpdateResult

Replace a document in the collection according to the specified arguments.

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

Since

3.7

Parameters

filter

the query filter to apply the the replace operation

replacement

the replacement document

options

the options to apply to the replace operation

Throws

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

abstract suspend fun replaceOne(    clientSession: ClientSession,     filter: Bson,     replacement: TDocument): UpdateResult

Replace a document in the collection according to the specified arguments.

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

filter

the query filter to apply the the replace operation

replacement

the replacement document

Throws

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

abstract suspend fun replaceOne(    clientSession: ClientSession,     filter: Bson,     replacement: TDocument,     options: ReplaceOptions): UpdateResult

Replace a document in the collection according to the specified arguments.

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

Since

3.7

Parameters

clientSession

the client session with which to associate this operation

filter

the query filter to apply the the replace operation

replacement

the replacement document

options

the options to apply to the replace operation

Throws

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