kmongo / org.litote.kmongo.coroutine / CoroutineCollection / findOneAndReplace

findOneAndReplace

suspend fun findOneAndReplace(filter: Bson, replacement: T, options: FindOneAndReplaceOptions = FindOneAndReplaceOptions()): T? (source)

Atomically find a document and replace it.

Parameters

filter - the query filter to apply the the replace operation

replacement - the replacement document

options - the options to apply to the operation

Return
the document that was replaced. 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

suspend fun findOneAndReplace(clientSession: ClientSession, filter: Bson, replacement: T, options: FindOneAndReplaceOptions = FindOneAndReplaceOptions()): T? (source)

Atomically find a document and replace it.

Parameters

clientSession - the client session with which to associate this operation

filter - the query filter to apply the the replace operation

replacement - the replacement document

options - the options to apply to the operation

Return
the document that was replaced. 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

Mongodb
.server.release 3.6

Since
1.7

suspend fun findOneAndReplace(filter: String, replacement: T, options: FindOneAndReplaceOptions = FindOneAndReplaceOptions()): T? (source)

Atomically find a document and replace it.

Parameters

filter - the query filter to apply the the replace operation

replacement - the replacement document

options - the options to apply to the operation

Return
the document that was replaced. 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

suspend fun findOneAndReplace(clientSession: ClientSession, filter: String, replacement: T, options: FindOneAndReplaceOptions = FindOneAndReplaceOptions()): T? (source)

Atomically find a document and replace it.

Parameters

clientSession - the client session with which to associate this operation

filter - the query filter to apply the the replace operation

replacement - the replacement document

options - the options to apply to the operation

Return
the document that was replaced. 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