@@ -21,7 +21,7 @@ Overview
2121--------
2222
2323In this guide, you can learn how to use a **change stream** to monitor real-time
24- changes to your database . A change stream is a {+mdb-server+} feature that
24+ changes to your data . A change stream is a {+mdb-server+} feature that
2525allows your application to subscribe to data changes on a collection, database,
2626or deployment.
2727
@@ -65,7 +65,7 @@ classes:
6565- ``Collection``: To monitor changes in the collection
6666
6767The following example opens a change stream on the ``restaurants`` collection
68- and outputs the operation type of changes as they occur. Select the
68+ and outputs the changes as they occur. Select the
6969:guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the corresponding
7070code.
7171
@@ -88,26 +88,24 @@ code.
8888 :language: csharp
8989
9090To begin watching for changes, run the application. Then, in a separate
91- application or shell, modify the ``restaurants`` collection. The following
92- example updates a document with a ``name`` field value of ``Blarney Castle``:
91+ application or shell, modify the ``restaurants`` collection. Updating a document
92+ with the ``"name"`` value of ``"Blarney Castle"`` results in the following
93+ change stream output:
9394
94- .. _csharp-change-stream-update:
95+ .. code-block:: sh
9596
96- .. literalinclude:: /includes/code-examples/change-streams/change-streams.cs
97- :start-after: start-modify-document
98- :end-before: end-modify-document
99- :language: csharp
100-
101- When you update the collection, the change stream application prints the type of change
102- as it occurs.
97+ { "_id" : { "_data" : "..." }, "operationType" : "update", "clusterTime" : Timestamp(...),
98+ "wallTime" : ISODate("..."), "ns" : { "db" : "sample_restaurants", "coll" : "restaurants" },
99+ "documentKey" : { "_id" : ObjectId("...") }, "updateDescription" : { "updatedFields" : { "cuisine" : "Irish" },
100+ "removedFields" : [], "truncatedArrays" : [] } }
103101
104102Modify the Change Stream Output
105103-------------------------------
106104
107105You can pass the ``pipeline`` parameter to the ``Watch()`` and ``WatchAsync()``
108106methods to modify the change stream output. This parameter allows you to watch
109107for only specified change events. Create the pipeline by using the
110- ``EmptyPipelineDefinition`` class, and appending the relevant aggregation stage methods.
108+ ``EmptyPipelineDefinition`` class and appending the relevant aggregation stage methods.
111109
112110You can specify the following aggregation stages in the ``pipeline`` parameter:
113111
@@ -121,7 +119,8 @@ You can specify the following aggregation stages in the ``pipeline`` parameter:
121119- ``$unset``
122120
123121To learn how to build an aggregation pipeline by using the
124- ``PipelineDefinitionBuilder`` class, see :ref:`csharp-builders-aggregation`.
122+ ``PipelineDefinitionBuilder`` class, see :ref:`csharp-builders-aggregation` in
123+ the Operations with Builders guide.
125124
126125The following example uses the ``pipeline`` parameter to open a change stream
127126that records only update operations. Select the :guilabel:`Asynchronous` or :guilabel:`Synchronous` tab to see the
@@ -164,7 +163,7 @@ of ``Watch()`` and ``WatchAsync()``:
164163 :widths: 30 70
165164 :header-rows: 1
166165
167- * - Property
166+ * - Option
168167 - Description
169168
170169 * - ``FullDocument``
@@ -200,7 +199,7 @@ of ``Watch()`` and ``WatchAsync()``:
200199 | ``StartAtOperationTime`` is mutually exclusive with ``ResumeAfter`` and ``StartAfter``.
201200
202201 * - ``MaxAwaitTime``
203- - | The maximum amount of time, in milliseconds, the server waits for new
202+ - | Specifies the maximum amount of time, in milliseconds, the server waits for new
204203 data changes to report to the change stream cursor before returning an
205204 empty batch. Defaults to 1000 milliseconds.
206205
@@ -211,14 +210,14 @@ of ``Watch()`` and ``WatchAsync()``:
211210 cursor and set this parameter to ``True``.
212211
213212 * - ``BatchSize``
214- - | The maximum number of change events to return in each batch of the
213+ - | Specifies the maximum number of change events to return in each batch of the
215214 response from the MongoDB cluster.
216215
217216 * - ``Collation``
218- - | The collation to use for the change stream cursor.
217+ - | Specifies the collation to use for the change stream cursor.
219218
220219 * - ``Comment``
221- - | A comment to attach to the operation.
220+ - | Specifies a comment to attach to the operation.
222221
223222.. _csharp-change-stream-pre-post-image:
224223
@@ -284,6 +283,15 @@ code.
284283 :end-before: end-change-stream-post-image
285284 :language: csharp
286285
286+ Running the preceding code example and updating a document with the ``"name"``
287+ value of ``"Blarney Castle"`` results in the following change stream output:
288+
289+ .. code-block:: sh
290+
291+ { "_id" : ObjectId("..."), "name" : "Blarney Castle", "restaurant_id" : "40366356",
292+ "cuisine" : "Traditional Irish", "address" : { "building" : "202-24", "coord" : [-73.925044200000002, 40.5595462],
293+ "street" : "Rockaway Point Boulevard", "zipcode" : "11697" }, "borough" : "Queens", "grades" : [...] }
294+
287295To learn more about pre-images and post-images, see
288296:manual:`Change Streams with Document Pre- and Post-Images </changeStreams#change-streams-with-document-pre--and-post-images>`
289297in the {+mdb-server+} manual.
0 commit comments