findOneAndReplace

abstract suspend fun findOneAndReplace(filter: Bson, replacement: TDocument): TDocument?

Atomically find a document and replace it.

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Parameters

filter

the query filter to apply the the replace operation

replacement

the replacement document 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


abstract suspend fun findOneAndReplace(    filter: Bson,     replacement: TDocument,     options: FindOneAndReplaceOptions): TDocument?

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 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


abstract suspend fun findOneAndReplace(    clientSession: ClientSession,     filter: Bson,     replacement: TDocument): TDocument?

Atomically find a document and replace it.

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Since

3.6

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 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


abstract suspend fun findOneAndReplace(    clientSession: ClientSession,     filter: Bson,     replacement: TDocument,     options: FindOneAndReplaceOptions): TDocument?

Atomically find a document and replace it.

Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.

Since

3.6

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 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