mongoc_client_watch - Man Page

mongoc_client_watch()

Synopsis

mongoc_change_stream_t*
mongoc_client_watch (mongoc_client_t *client,
                     const bson_t *pipeline,
                     const bson_t *opts);

A helper function to create a change stream. It is preferred to call this function over using a raw aggregation to create a change stream.

This function uses the read preference and read concern of the client. If the change stream needs to re-establish connection, the same read preference will be used. This may happen if the change stream encounters a resumable error.

WARNING:

A change stream is only supported with majority read concern.

This function is considered a retryable read operation. Upon a transient error (a network error, errors due to replica set failover, etc.) the operation is safely retried once. If retryreads is false in the URI (see mongoc_uri_t) the retry behavior does not apply.

Parameters

opts may be NULL or a BSON document with additional command options:

Returns

A newly allocated mongoc_change_stream_t which must be freed with mongoc_change_stream_destroy when no longer in use. The returned mongoc_change_stream_t is never NULL. If there is an error, it can be retrieved with mongoc_change_stream_error_document, and subsequent calls to mongoc_change_stream_next will return false.

See Also

mongoc_database_watch

mongoc_collection_watch

Author

MongoDB, Inc

Info

Apr 09, 2021 1.17.5 libmongoc