Table of Contents

Method WatchAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

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

collection IMongoCollection<TDocument>

The collection.

options ChangeStreamOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IChangeStreamCursor<ChangeStreamDocument<TDocument>>>

A change stream.

Type Parameters

TDocument

The 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

collection IMongoCollection<TDocument>

The collection.

session IClientSessionHandle

The session.

options ChangeStreamOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IChangeStreamCursor<ChangeStreamDocument<TDocument>>>

A change stream.

Type Parameters

TDocument

The type of the document.