findOneAndUpdate

abstract suspend fun findOneAndUpdate(filter: Bson, update: Bson): TDocument?

Atomically find a document and update it.

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

Parameters

filter

a document describing the query filter, which may not be null.

update

a document describing the update, which may not be null. The update to apply must include only update operators. filter, then null will be returned


abstract suspend fun findOneAndUpdate(    filter: Bson,     update: Bson,     options: FindOneAndUpdateOptions): TDocument?

Atomically find a document and update it.

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

Parameters

filter

a document describing the query filter, which may not be null.

update

a document describing the update, which may not be null. The update to apply must include only update operators.

options

the options to apply to the operation 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 findOneAndUpdate(    clientSession: ClientSession,     filter: Bson,     update: Bson): TDocument?

Atomically find a document and update 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

a document describing the query filter, which may not be null.

update

a document describing the update, which may not be null. The update to apply must include only update operators. filter, then null will be returned


abstract suspend fun findOneAndUpdate(    clientSession: ClientSession,     filter: Bson,     update: Bson,     options: FindOneAndUpdateOptions): TDocument?

Atomically find a document and update 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

a document describing the query filter, which may not be null.

update

a document describing the update, which may not be null. The update to apply must include only update operators.

options

the options to apply to the operation 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