Skip to content

Commit e4df007

Browse files
skerschbkay-kim
authored andcommitted
DOCSP-1350 with php removed
1 parent 88291f5 commit e4df007

File tree

2 files changed

+76
-5
lines changed

2 files changed

+76
-5
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ examples:
9292
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-java-driver/master/driver-legacy/src/examples/documentation/DocumentationSamples.java -o ${DRIVERS_PATH}/DocumentationSamples.java
9393
curl -SfL https://raw.githubusercontent.com/mongodb/node-mongodb-native/2.2/test/functional/examples_tests.js -o ${DRIVERS_PATH}/examples_tests.js
9494
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-ruby-driver/master/spec/mongo/shell_examples_spec.rb -o ${DRIVERS_PATH}/shell_examples_spec.rb
95+
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-ruby-driver/master/spec/mongo/change_stream_examples_spec.rb -o ${DRIVERS_PATH}/change_stream_examples_spec.rb
9596
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-scala-driver/master/driver/src/it/scala/org/mongodb/scala/DocumentationExampleSpec.scala -o ${DRIVERS_PATH}/DocumentationExampleSpec.scala
9697
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/tests/MongoDB.Driver.Examples/DocumentationExamples.cs -o ${DRIVERS_PATH}/DocumentationExamples.cs
9798
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/tests/MongoDB.Driver.Examples/ChangeStreamExamples.cs -o ${DRIVERS_PATH}/ChangeStreamExamples.cs
9899
curl -SfL https://raw.githubusercontent.com/mongodb/mongo-c-driver/master/tests/test-mongoc-sample-commands.c -o ${DRIVERS_PATH}/test-mongoc-sample-commands.c
99100
curl -Sfl https://raw.githubusercontent.com/mongodb/mongo-java-driver-reactivestreams/master/examples/documentation/src/DocumentationSamples.java -o ${DRIVERS_PATH}/AsyncDocumentationSamples.java
101+

source/tutorial/change-streams-example.txt

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ Change Stream Examples
5555
The examples below assume that you have `connected to a MongoDB replica set and have accessed a database
5656
<http://mongoc.org/libmongoc/current/tutorial.html#making-a-connection/>`__
5757
that contains an ``inventory`` collection.
58+
59+
- id: ruby
60+
content: |
61+
The examples below assume that you have `connected to a MongoDB replica set and have accessed a database
62+
<https://docs.mongodb.com/ruby-driver/master/tutorials/ruby-driver-create-client/>`_
63+
that contains an ``inventory`` collection.
64+
5865

5966
Open A Change Stream
6067
--------------------
@@ -104,6 +111,16 @@ as long as a connection to the MongoDB deployment remains open *and* the collect
104111
:dedent: 0
105112
:start-after: Start Changestream Example 1
106113
:end-before: End Changestream Example 1
114+
115+
- id: ruby
116+
content: |
117+
.. class:: copyable-code
118+
119+
.. literalinclude:: /driver-examples/change_stream_examples_spec.rb
120+
:language: ruby
121+
:dedent: 4
122+
:start-after: Start Changestream Example 1
123+
:end-before: End Changestream Example 1
107124

108125
In order to retrieve the data change event notifications, iterate
109126
the change stream ``cursor``.
@@ -147,7 +164,13 @@ Lookup Full Document for Update Operations
147164
To return the most current majority-committed version of the updated
148165
document, pass ``"FullDocument = ChangeStreamFullDocumentOption.UpdateLookup"`` to the
149166
:method:`collection.Watch()` method.
150-
167+
168+
- id: ruby
169+
content: |
170+
By default, change streams only return the delta of fields during the update operation.
171+
To return the most current majority-committed version of the updated
172+
document, pass ``full_document: 'updateLookup'`` to the
173+
:method:`watch()` method.
151174

152175
If there are one or more majority-committed operations that modified the
153176
updated document *after* the update operation but *before* the lookup, the
@@ -206,6 +229,16 @@ update operation.
206229
:dedent: 0
207230
:start-after: Start Changestream Example 2
208231
:end-before: End Changestream Example 2
232+
233+
- id: ruby
234+
content: |
235+
.. class:: copyable-code
236+
237+
.. literalinclude:: /driver-examples/change_stream_examples_spec.rb
238+
:language: php
239+
:dedent: 4
240+
:start-after: Start Changestream Example 2
241+
:end-before: End Changestream Example 2
209242

210243
See :ref:`change-stream-output` for more information on the change stream
211244
response document format.
@@ -268,16 +301,18 @@ response document format.
268301
Resume a Change Stream
269302
----------------------
270303

271-
Each change stream response document has an ``_id`` field that contains a
272-
document containing a resume token. The ``resumeToken`` includes the change
273-
stream notification id. You can use the ``resumeToken`` document to resume
274-
notification after a specific notification.
304+
275305

276306
.. tabs-drivers::
277307

278308
tabs:
279309
- id: python
280310
content: |
311+
Each change stream response document has an ``_id`` field that contains a
312+
document containing a resume token. The ``resumeToken`` includes the change
313+
stream notification id. You can use the ``resumeToken`` document to resume
314+
notification after a specific notification.
315+
281316
In the example below, the ``resumeAfter`` modifier takes a parameter that must resolve to a resume
282317
token. Passing the ``resumeToken`` to the ``resumeAfter`` modifier directs
283318
the change stream to attempt to resume notifications starting at the
@@ -293,6 +328,11 @@ notification after a specific notification.
293328

294329
- id: java-sync
295330
content: |
331+
Each change stream response document has an ``_id`` field that contains a
332+
document containing a resume token. The ``resumeToken`` includes the change
333+
stream notification id. You can use the ``resumeToken`` document to resume
334+
notification after a specific notification.
335+
296336
In the example below, the ``resumeAfter()`` method takes a parameter that must resolve to a resume
297337
token. Passing the ``resumeToken`` to the ``resumeAfter()`` method directs
298338
the change stream to attempt to resume notifications starting at the
@@ -308,6 +348,11 @@ notification after a specific notification.
308348

309349
- id: csharp
310350
content: |
351+
Each change stream response document has an ``_id`` field that contains a
352+
document containing a resume token. The ``resumeToken`` includes the change
353+
stream notification id. You can use the ``resumeToken`` document to resume
354+
notification after a specific notification.
355+
311356
In the example below, the ``resumeToken`` is retrieved from the last change stream document
312357
and passed to the ``Watch()`` method as an option. Passing the ``resumeToken``
313358
to the ``Watch()`` method directs
@@ -324,6 +369,11 @@ notification after a specific notification.
324369

325370
- id: c
326371
content: |
372+
Each change stream response document has an ``_id`` field that contains a
373+
document containing a resume token. The ``resumeToken`` includes the change
374+
stream notification id. You can use the ``resumeToken`` document to resume
375+
notification after a specific notification.
376+
327377
In the example below, the ``resumeAfter`` option is appended to the stream options
328378
to recreate the stream after it has been destroyed. Passing the ``_id`` to
329379
the change stream attempts to resume notifications starting at the
@@ -336,6 +386,25 @@ notification after a specific notification.
336386
:dedent: 0
337387
:start-after: Start Changestream Example 3
338388
:end-before: End Changestream Example 3
389+
390+
- id: ruby
391+
content: |
392+
Each change stream response document has an ``_id`` field which can be passed
393+
to the ``watch()`` method, indicating to the method at what point in the
394+
iteration of the change stream it should resume.
395+
396+
In the example below, the ``resumeAfter`` option is passed to the ``watch()`` method
397+
with a value of the ``_id`` of the last document processed, in order to recreate the
398+
stream after it has been destroyed. Passing the ``_id`` to the change stream attempts
399+
to resume notifications starting at the operation specified.
400+
401+
.. class:: copyable-code
402+
403+
.. literalinclude:: /driver-examples/change_stream_examples_spec.rb
404+
:language: ruby
405+
:dedent: 4
406+
:start-after: Start Changestream Example 3
407+
:end-before: End Changestream Example 3
339408

340409

341410
As long as that operation has not rolled off the :term:`oplog`, the

0 commit comments

Comments
 (0)