kmongo / org.litote.kmongo.rxjava2 / com.mongodb.reactivestreams.client.MongoCollection / findOneAndUpdate

findOneAndUpdate

fun <T : Any> MongoCollection<T>.findOneAndUpdate(filter: String, update: String, options: FindOneAndUpdateOptions = FindOneAndUpdateOptions()): Maybe<T> (source)

Atomically find a document and update it.

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 operation

Return
the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned

fun <T : Any> MongoCollection<T>.findOneAndUpdate(clientSession: ClientSession, filter: String, update: String, options: FindOneAndUpdateOptions = FindOneAndUpdateOptions()): Maybe<T> (source)

Atomically find a document and update it.

Parameters

clientSession - the client session

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 operation

Return
the document that was updated. Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be returned