@@ -20,10 +20,10 @@ Monitor Data Changes
20
20
Overview
21
21
--------
22
22
23
- In 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
25
- allows your application to subscribe to data changes on a collection, database,
26
- or deployment .
23
+ In this guide, you can learn how to use the {+driver-short+} to monitor a **change stream**,
24
+ allowing you to view real-time changes to your database. A change stream is a {+mdb-server+} feature that
25
+ publishes data changes on a collection, database, or deployment. Your application can
26
+ subscribe to a change stream and use events to perform other actions .
27
27
28
28
Sample Data
29
29
~~~~~~~~~~~
@@ -46,13 +46,16 @@ Open a Change Stream
46
46
47
47
To open a change stream, call the ``watch()`` method. The instance on which you
48
48
call the ``watch()`` method on determines the scope of events that the change
49
- stream listens for. You can call the ``watch()`` method on the following
49
+ stream listens for. You can call the ``watch()`` method on instances of the following
50
50
classes:
51
51
52
52
- ``MongoClient``: To monitor all changes in the MongoDB deployment
53
53
- ``MongoDatabase``: To monitor changes in all collections in the database
54
54
- ``MongoCollection``: To monitor changes in the collection
55
55
56
+ Open a Change Stream Example
57
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58
+
56
59
The following example opens a change stream on the ``restaurants`` collection
57
60
and prints changes as they occur:
58
61
@@ -64,8 +67,8 @@ and prints changes as they occur:
64
67
:dedent:
65
68
66
69
To begin watching for changes, run the application. Then, in a separate
67
- application or shell, modify the ``restaurants`` collection. The following
68
- example updates a document with a ``name`` field value of `` Blarney Castle``:
70
+ application or shell, perform a write operation on the ``restaurants`` collection. The
71
+ following example updates a document in which the value of the ``name`` is ``" Blarney Castle" ``:
69
72
70
73
.. _kotlin-sync-change-stream-update:
71
74
@@ -113,7 +116,7 @@ Modify the Change Stream Output
113
116
114
117
You can pass the ``pipeline`` parameter to the ``watch()`` method to modify the
115
118
change stream output. This parameter allows you to watch for only specified
116
- change events. Format the parameter as a list of objects that each represent an
119
+ change events. Format the parameter as a list of objects that each represents an
117
120
aggregation stage.
118
121
119
122
You can specify the following stages in the ``pipeline`` parameter:
@@ -127,6 +130,9 @@ You can specify the following stages in the ``pipeline`` parameter:
127
130
- ``$set``
128
131
- ``$unset``
129
132
133
+ Open a Change Stream with a Pipeline Example
134
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135
+
130
136
The following example uses the ``pipeline`` parameter to open a change stream
131
137
that records only update operations:
132
138
@@ -142,10 +148,10 @@ To learn more about modifying your change stream output, see the
142
148
</changeStreams/#modify-change-stream-output>` section in the {+mdb-server+}
143
149
manual.
144
150
145
- Modify `` watch()`` Behavior
146
- ---------------------------
151
+ Modify watch() Behavior
152
+ -----------------------
147
153
148
- The ``watch()`` method can be modified by chaining methods to the ``ChangeStreamIterable``
154
+ You can modify the ``watch()`` by chaining methods to the ``ChangeStreamIterable``
149
155
object returned by the ``watch()`` method call. If you don't specify any options, the
150
156
driver does not customize the operation.
151
157
@@ -186,7 +192,7 @@ of ``watch()``:
186
192
milliseconds.
187
193
188
194
* - ``toCollection()``
189
- - | Appends all elements to the given destination collection.
195
+ - | Inserts all elements into the given destination collection.
190
196
191
197
For a complete list of methods you can use to configure the ``watch()`` method, see
192
198
the `ChangeStreamIterable <{+api+}/com.mongodb.kotlin.client/-change-stream-iterable/index.html>`__
0 commit comments