diff --git a/source/includes/try-next-warning.rst b/source/includes/try-next-warning.rst new file mode 100644 index 000000000..800ba355e --- /dev/null +++ b/source/includes/try-next-warning.rst @@ -0,0 +1,6 @@ +.. warning:: + + The `tryNext() <{+api+}/classes/ChangeStream.html#tryNext>`_ method does not + automatically update the change stream's `resumeToken. + <{+api+}/classes/ChangeStream.html#resumeToken>`_ If you require an updated + ``resumeToken``, use the ``next()`` method. \ No newline at end of file diff --git a/source/monitoring-and-logging/change-streams.txt b/source/monitoring-and-logging/change-streams.txt index 5d7588379..c25e622ed 100644 --- a/source/monitoring-and-logging/change-streams.txt +++ b/source/monitoring-and-logging/change-streams.txt @@ -44,6 +44,8 @@ section for more information on the settings you can configure with this object. The ``watch()`` method returns an instance of a `ChangeStream <{+api+}/classes/ChangeStream.html>`__. You can read events from change streams by iterating over them or listening for events. +.. include:: /includes/changestream-paradigm-warning.rst + Select the tab that corresponds to the way you want to read events from the change stream: @@ -72,6 +74,7 @@ read events from the change stream: - ``next()`` to request the next document in the stream - ``close()`` to close the ChangeStream + .. include:: /includes/try-next-warning.rst .. tab:: :tabid: Event @@ -98,7 +101,7 @@ read events from the change stream: changeStream.close(); -.. include:: /includes/changestream-paradigm-warning.rst +.. _node-usage-watch: Examples --------