@@ -9,9 +9,13 @@ Watch for Changes
99You can keep track of changes to data in MongoDB, such as changes to a
1010collection, database, or deployment, by opening a **change stream**. A change
1111stream allows applications to watch for changes to data and react to them.
12- The change stream returns **change event** documents when changes occur.
13- You can open a change stream by calling the ``watch()`` method on
14- a ``MongoCollection``, ``MongoDatabase``, or ``MongoClient`` object:
12+
13+ The change stream returns **change event** documents when changes occur. A
14+ change event contains information about the updated data.
15+
16+ Open a change stream by calling the ``watch()`` method on a
17+ ``MongoCollection``, ``MongoDatabase``, or ``MongoClient`` object as shown in
18+ the following code example:
1519
1620.. code-block:: java
1721
@@ -134,27 +138,29 @@ pipeline filters out the ``delete`` operation:
134138
135139 Received a change to the collection: ChangeStreamDocument{
136140 operationType=OperationType{value='insert'},
137- resumeToken={"_data": "825EC ..."},
141+ resumeToken={"_data": "825E ..."},
138142 namespace=sample_mflix.movies,
139143 destinationNamespace=null,
140144 fullDocument=Document{{_id=5ec3..., test=sample movie document}},
141145 documentKey={"_id": {"$oid": "5ec3..."}},
142146 clusterTime=Timestamp{...},
143147 updateDescription=null,
144148 txnNumber=null,
145- lsid=null
149+ lsid=null,
150+ wallTime=BsonDateTime{value=1657...}
146151 }
147152 Received a change to the collection: ChangeStreamDocument{
148153 operationType=OperationType{value='update'},
149- resumeToken={"_data": "825EC ..."},
154+ resumeToken={"_data": "825E ..."},
150155 namespace=sample_mflix.movies,
151156 destinationNamespace=null,
152157 fullDocument=Document{{_id=5ec3..., test=sample movie document, field2=sample movie document update}},
153158 documentKey={"_id": {"$oid": "5ec3..."}},
154159 clusterTime=Timestamp{...},
155160 updateDescription=UpdateDescription{removedFields=[], updatedFields={"field2": "sample movie document update"}},
156161 txnNumber=null,
157- lsid=null
162+ lsid=null,
163+ wallTime=BsonDateTime{value=1657...}
158164 }
159165
160166You should also see output from the ``WatchCompanion`` application that
0 commit comments