Method Watch

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

Namespace

MongoDB.Driver

Assembly

MongoDB.Driver.dll

Watch(IMongoCollection, ChangeStreamOptions, CancellationToken)

Watches changes on the collection.

public static IChangeStreamCursor<ChangeStreamDocument<TDocument>> Watch<TDocument>(this IMongoCollection<TDocument> collection, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection

The collection.

options ChangeStreamOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

IChangeStreamCursor<ChangeStreamDocument>

A change stream.

Type Parameters

TDocument

The type of the document.

Watch(IMongoCollection, IClientSessionHandle, ChangeStreamOptions, CancellationToken)

Watches changes on the collection.

public static IChangeStreamCursor<ChangeStreamDocument<TDocument>> Watch<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, ChangeStreamOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection

The collection.

session IClientSessionHandle

The session.

options ChangeStreamOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

IChangeStreamCursor<ChangeStreamDocument>

A change stream.

Type Parameters

TDocument

The type of the document.