kmongo / org.litote.kmongo / com.mongodb.client.MongoCollection / updateOneById

updateOneById

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

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

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

Exceptions

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

Return
the result of the update one operation

fun <T : Any> MongoCollection<T>.updateOneById(id: Any, vararg updates: SetTo<*>, options: UpdateOptions = UpdateOptions()): UpdateResult (source)

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

Parameters

id - the object id

updates - the setTo describing the updates

options - the options to apply to the update operation

Exceptions

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

Return
the result of the update one operation

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

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

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

Exceptions

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

Return
the result of the update one operation