updateOneById

fun <T : Any> MongoCollection<T>.updateOneById(id: Any, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult

Update a single document in the collection according to the specified arguments.

Return

the result of the update one operation

Parameters

id

the object id

update

the update object

options

the options to apply to the update operation

updateOnlyNotNullProperties

if true do not change null properties

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>.updateOneById(id: Any, vararg updates: SetTo<*>, options: UpdateOptions = UpdateOptions()): UpdateResult

Update a single document in the collection according to the specified arguments.

Return

the result of the update one operation

Parameters

id

the object id

updates

the setTo describing the updates

options

the options to apply to the update 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>.updateOneById(clientSession: ClientSession, id: Any, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult

Update a single document in the collection according to the specified arguments.

Return

the result of the update one operation

Parameters

clientSession

the client session with which to associate this operation

id

the object id

update

the update object

options

the options to apply to the update operation

updateOnlyNotNullProperties

if true do not change null properties

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