Method WatchAsync
WatchAsync<TDocument>(IMongoCollection<TDocument>, ChangeStreamOptions, CancellationToken)
Watches changes on the collection.
public static Task<IChangeStreamCursor<ChangeStreamDocument<TDocument>>> WatchAsync<TDocument>(this IMongoCollection<TDocument> collection, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
optionsChangeStreamOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IChangeStreamCursor<ChangeStreamDocument<TDocument>>>
A change stream.
Type Parameters
TDocumentThe type of the document.
WatchAsync<TDocument>(IMongoCollection<TDocument>, IClientSessionHandle, ChangeStreamOptions, CancellationToken)
Watches changes on the collection.
public static Task<IChangeStreamCursor<ChangeStreamDocument<TDocument>>> WatchAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
sessionIClientSessionHandleThe session.
optionsChangeStreamOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IChangeStreamCursor<ChangeStreamDocument<TDocument>>>
A change stream.
Type Parameters
TDocumentThe type of the document.