Skip to content

Commit 617bab8

Browse files
committed
edits
1 parent cc7851f commit 617bab8

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

source/read/change-streams.txt

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ Overview
2121
--------
2222

2323
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
24+
changes to your data. A change stream is a {+mdb-server+} feature that
2525
allows your application to subscribe to data changes on a collection, database,
2626
or deployment.
2727

28-
When using the {+driver-short+}, you can instantiate a ``MongoDB\ChangeStream`` to
28+
When using the {+php-library+}, you can instantiate a ``MongoDB\ChangeStream`` to
2929
monitor data changes.
3030

3131
Sample Data
@@ -49,8 +49,8 @@ Open a Change Stream
4949
--------------------
5050

5151
To open a change stream, call the ``watch()`` method. The instance on which you
52-
call the ``watch()`` method on determines the scope of events that the change
53-
stream listens for. You can call the ``watch()`` method on the following
52+
call the ``watch()`` method determines the scope of events that the change
53+
stream monitors. You can call the ``watch()`` method on the following
5454
classes:
5555

5656
- ``MongoDB\Client``: Monitor all changes in the MongoDB deployment
@@ -84,11 +84,10 @@ as it occurs. The printed change event resembles the following output:
8484
.. code-block:: bash
8585
:copyable: false
8686

87-
{ "_id" : { "_data" : "..." }, "operationType" : "update", "clusterTime" :
88-
{ "$timestamp" : { ... }, "wallTime" : { "$date" : ... }, "ns" :
89-
{ "db" : "sample_restaurants", "coll" : "restaurants" }, "documentKey" :
90-
{ "_id" : { "$oid" : "..." } }, "updateDescription" : { "updatedFields" :
91-
{ "cuisine" : "Irish" }, "removedFields" : [ ], "truncatedArrays" : [ ] } }
87+
{"_id":{"_data":"..."},"operationType":"update","clusterTime":{"$timestamp":{...},
88+
"wallTime":{"$date":...},"ns":{"db":"sample_restaurants","coll":"restaurants"},
89+
"documentKey":{"_id":{"$oid":"..."}},"updateDescription":{"updatedFields":
90+
{"cuisine":"Irish"},"removedFields":[],"truncatedArrays":[]}}}
9291

9392
Modify the Change Stream Output
9493
-------------------------------
@@ -144,7 +143,7 @@ you can set in the array:
144143
| Each change stream event document includes a resume token as the ``_id``
145144
field. Pass the entire ``_id`` field of the change event document that
146145
represents the operation you want to resume after.
147-
| ``resume_after`` is mutually exclusive with ``startAfter`` and ``startAtOperationTime``.
146+
| This option is mutually exclusive with ``startAfter`` and ``startAtOperationTime``.
148147

149148
* - ``startAfter``
150149
- | Instructs ``watch()`` to start a new change stream after the
@@ -153,17 +152,17 @@ you can set in the array:
153152
| Each change stream event document includes a resume token as the ``_id``
154153
field. Pass the entire ``_id`` field of the change event document that
155154
represents the operation you want to resume after.
156-
| ``start_after`` is mutually exclusive with ``resume_after`` and ``start_at_operation_time``.
155+
| This option is mutually exclusive with ``resumeAfter`` and ``startAtOperationTime``.
157156

158157
* - ``typeMap``
159-
- | Sets the maximum number of change events to return in each batch of the
160-
response from the MongoDB cluster.
158+
- | The type map to apply to cursors, which determines how BSON documents are converted
159+
to PHP values.
161160

162161
* - ``collation``
163162
- | Sets the collation to use for the change stream cursor.
164163

165164
For a full list of ``watch()`` options, see `MongoDB\\Collection::watch()
166-
<{+api+}/reference/method/MongoDBCollection-watch/>`__ in the API
165+
<{+api+}/method/MongoDBCollection-watch/>`__ in the API
167166
documentation.
168167

169168
.. _php-change-stream-pre-post-image:
@@ -184,26 +183,26 @@ options in an array parameter to ``watch()``.
184183

185184
The **pre-image** is the full version of a document *before* a change. To include the
186185
pre-image in the change stream event, set the ``fullDocumentBeforeChange`` field
187-
to one of the following strings:
186+
to one of the following values:
188187

189188
- ``MongoDB\Operation\Watch::FULL_DOCUMENT_BEFORE_CHANGE_WHEN_AVAILABLE``: The change event includes
190189
a pre-image of the modified document for change events. If the pre-image is not available, this
191190
change event field has a ``null`` value.
192191
- ``MongoDB\Operation\Watch::FULL_DOCUMENT_BEFORE_CHANGE_REQUIRED``: The change event includes a pre-image
193192
of the modified document for change events. If the pre-image is not available, the
194-
{+driver-short+} raises an error.
193+
{+php-library+} raises an error.
195194

196195
The **post-image** is the full version of a document *after* a change. To include the
197196
post-image in the change stream event, set the ``fullDocument`` field to
198-
one of the following strings:
197+
one of the following values:
199198

200199
- ``MongoDB\Operation\Watch::FULL_DOCUMENT_UPDATE_LOOKUP``: The change event includes a
201-
copy of the entire changed document from some time after the change.
200+
copy of the entire changed document from some time after the change.
202201
- ``MongoDB\Operation\Watch::FULL_DOCUMENT_WHEN_AVAILABLE``: The change event includes
203202
a post-image of the modified document for change events only if the post-image is available.
204203
- ``MongoDB\Operation\Watch::FULL_DOCUMENT_REQUIRED``: The change event includes a post-image
205204
of the modified document for change events. If the post-image is not available, the
206-
{+driver-short+} raises an error.
205+
{+php-library+} raises an error.
207206

208207
The following example calls the ``watch()`` method on a collection and includes the post-image
209208
of updated documents by setting the ``fullDocument`` option:
@@ -221,17 +220,15 @@ code:
221220

222221
.. code-block:: bash
223222
:copyable: false
224-
:emphasize-lines: 3,4,5,6
225-
226-
{ "_id" : { "_data" : "..." }, "operationType" : "update", "clusterTime" :
227-
{ "$timestamp" : { ... } }, "wallTime" : { "$date" : ... },
228-
"fullDocument" : { "_id" : { "$oid" : "..." }, "address" : { "building" : "202-24",
229-
"coord" : [ -73.925044200000002093, 40.559546199999999772 ], "street" :
230-
"Rockaway Point Boulevard", "zipcode" : "11697" }, "borough" : "Queens", "cuisine" :
231-
"Irish", "grades" : [ ... ], "name" : "Blarney Castle", "restaurant_id" : "40366356" },
232-
"ns" : { "db" : "sample_restaurants", "coll" : "restaurants" }, "documentKey" :
233-
{ "_id" : { "$oid" : "..." } }, "updateDescription" : { "updatedFields" :
234-
{ "cuisine" : "Irish" }, "removedFields" : [ ], "truncatedArrays" : [ ] } }
223+
:emphasize-lines: 2-5
224+
225+
{"_id":{"_data":"..."},"operationType":"update","clusterTime":...},"wallTime":{"$date":...},
226+
"fullDocument":{"_id":{"$oid":"..."},"address": {"building":"202-24","coord":
227+
[-73.925044200000002093,40.559546199999999772], "street":"Rockaway Point Boulevard",
228+
"zipcode":"11697"},"borough":"Queens","cuisine":"Irish","grades":[...],"name":"Blarney Castle",
229+
"restaurant_id":"40366356"},"ns":{"db":"sample_restaurants","coll":"restaurants"},
230+
"documentKey":{"_id":{"$oid":"..."}},"updateDescription":{"updatedFields":{"cuisine":"Irish"},
231+
"removedFields":[],"truncatedArrays":[]}}
235232

236233
.. tip::
237234

0 commit comments

Comments
 (0)