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

updateOne

fun <T> MongoCollection<T>.updateOne(filter: String, update: String, options: UpdateOptions = UpdateOptions()): UpdateResult (source)

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

Parameters

filter - a document describing the query filter

update - a document describing the update. The update to apply must include only update operators.

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>.updateOne(filter: String, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult (source)

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

Parameters

filter - a document describing the query filter

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 <reified T : Any> MongoCollection<T>.updateOne(target: T, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult (source)

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

Parameters

target - the update object - must have an non null id

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> MongoCollection<T>.updateOne(filter: Bson, target: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult (source)

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

Parameters

filter - a document describing the query filter

update - the update object

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 : Any> MongoCollection<T>.updateOne(filter: Bson, vararg updates: SetTo<*>, updateOptions: UpdateOptions = UpdateOptions()): UpdateResult (source)

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

Parameters

filter - a document describing the query filter

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>.updateOne(clientSession: ClientSession, filter: String, update: String, options: UpdateOptions = UpdateOptions()): 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

filter - a document describing the query filter

update - a document describing the update. The update to apply must include only update operators.

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>.updateOne(clientSession: ClientSession, filter: String, update: Any, options: UpdateOptions = UpdateOptions(), updateOnlyNotNullProperties: Boolean = UpdateConfiguration.updateOnlyNotNullProperties): UpdateResult (source)
fun <T> MongoCollection<T>.updateOne(clientSession: ClientSession, filter: Bson, target: 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

filter - a document describing the query filter

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 <reified T : Any> MongoCollection<T>.updateOne(clientSession: ClientSession, target: T, 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

target - the update object - must have an non null id

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>.updateOne(clientSession: ClientSession, filter: Bson, vararg updates: SetTo<*>, updateOptions: UpdateOptions = UpdateOptions()): 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

filter - a document describing the query filter

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