Skip to content

Commit 92b0fb8

Browse files
DOCSP-17306 Fix Change Streams Note (#198)
Co-authored-by: Nathan <[email protected]>
1 parent d085e74 commit 92b0fb8

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

source/usage-examples/changeStream.txt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,6 @@ methods presented above:
8282
- :node-api-4.0:`Db.watch() </classes/db.html#watch>`,
8383
- :node-api-4.0:`MongoClient.watch() API documentation </classes/mongoclient.html#watch>`
8484

85-
.. note::
86-
87-
Change events that contain information on update operations only return the modified
88-
fields by default rather than the full updated document. You can configure
89-
your change stream to also return the most current version of the document
90-
by setting the ``fullDocument`` field of the options object to
91-
``"updateLookup"`` as follows:
92-
93-
.. code-block:: javascript
94-
95-
const changeStream = collection.watch();
96-
const options = { fullDocument: "updateLookup" };
97-
changeStream.on("change", callbackFunction, options);
98-
9985
Example
10086
-------
10187

@@ -141,3 +127,21 @@ following:
141127
ns: { db: 'sample_mflix', coll: 'movies' },
142128
documentKey: { _id: 5ec3... },
143129
}
130+
131+
.. note:: Receive Full Documents From Updates
132+
133+
Change events that contain information on update operations only return the modified
134+
fields by default rather than the full updated document. You can configure
135+
your change stream to also return the most current version of the document
136+
by setting the ``fullDocument`` field of the options object to
137+
``"updateLookup"`` as follows:
138+
139+
.. code-block:: javascript
140+
:emphasize-lines: 1, 5
141+
142+
const options = { fullDocument: "updateLookup" };
143+
// This could be any pipeline.
144+
const pipeline = [];
145+
146+
const changeStream = collection.watch(pipeline, options);
147+

0 commit comments

Comments
 (0)