replaceOneById

fun <T : Any> MongoCollection<T>.replaceOneById(id: Any, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult

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

Return

the result of the replace one operation

Parameters

id

the object id

replacement

the replacement document

options

the options to apply to the replace operation

Throws

com.mongodb.MongoWriteException

if the write failed due some other failure specific to the update command

com.mongodb.MongoWriteConcernException

if the write failed due being unable to fulfil the write concern

com.mongodb.MongoException

if the write failed due some other failure


fun <T : Any> MongoCollection<T>.replaceOneById(clientSession: ClientSession, id: Any, replacement: T, options: ReplaceOptions = ReplaceOptions()): UpdateResult

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

Return

the result of the replace one operation

Parameters

clientSession

the client session with which to associate this operation

id

the object id

replacement

the replacement document

options

the options to apply to the replace operation

Throws

com.mongodb.MongoWriteException

if the write failed due some other failure specific to the update command

com.mongodb.MongoWriteConcernException

if the write failed due being unable to fulfil the write concern

com.mongodb.MongoException

if the write failed due some other failure