Method UpdateOneAsync

| MongoDB CSharp Driver API Reference (original) (raw)

Namespace

MongoDB.Driver

Assembly

MongoDB.Driver.dll

UpdateOneAsync(IMongoCollection, Expression<Func<TDocument, bool>>, UpdateDefinition, UpdateOptions, CancellationToken)

Updates a single document.

public static Task<UpdateResult> UpdateOneAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> update, UpdateOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection

The collection.

filter Expression<Func<TDocument, bool>>

The filter.

update UpdateDefinition

The update.

options UpdateOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<UpdateResult>

The result of the update operation.

Type Parameters

TDocument

The type of the document.

UpdateOneAsync(IMongoCollection, IClientSessionHandle, Expression<Func<TDocument, bool>>, UpdateDefinition, UpdateOptions, CancellationToken)

Updates a single document.

public static Task<UpdateResult> UpdateOneAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> update, UpdateOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection

The collection.

session IClientSessionHandle

The session.

filter Expression<Func<TDocument, bool>>

The filter.

update UpdateDefinition

The update.

options UpdateOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<UpdateResult>

The result of the update operation.

Type Parameters

TDocument

The type of the document.