Method ReplaceOneAsync
ReplaceOneAsync(FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)
Replaces a single document.
Task<ReplaceOneResult> ReplaceOneAsync(FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default)
Parameters
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
ReplaceOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<ReplaceOneResult>
The result of the replacement.
ReplaceOneAsync(FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)
Replaces a single document.
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
Task<ReplaceOneResult> ReplaceOneAsync(FilterDefinition<TDocument> filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default)
Parameters
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
UpdateOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<ReplaceOneResult>
The result of the replacement.
ReplaceOneAsync(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)
Replaces a single document.
Task<ReplaceOneResult> ReplaceOneAsync(IClientSessionHandle session, FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
ReplaceOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<ReplaceOneResult>
The result of the replacement.
ReplaceOneAsync(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)
Replaces a single document.
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
Task<ReplaceOneResult> ReplaceOneAsync(IClientSessionHandle session, FilterDefinition<TDocument> filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
UpdateOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<ReplaceOneResult>
The result of the replacement.