@@ -250,6 +250,38 @@ Open A Change Stream
250
250
:start-after: Start Changestream Example 1
251
251
:end-before: End Changestream Example 1
252
252
253
+ - id: swift-sync
254
+ content: |
255
+
256
+ The Swift (Sync) examples below assume that you have
257
+ `connected to a MongoDB replica set and have accessed a
258
+ database
259
+ <https://mongodb.github.io/mongo-swift-driver/MongoSwiftSync/Classes/MongoClient.html>`__
260
+ that contains an ``inventory`` collection.
261
+
262
+
263
+ .. literalinclude:: /driver-examples/swiftSync.swift
264
+ :language: swift
265
+ :dedent: 8
266
+ :start-after: Start Changestream Example 1
267
+ :end-before: End Changestream Example 1
268
+
269
+ - id: swift-async
270
+ content: |
271
+
272
+ The Swift (Async) examples below assume that you have
273
+ `connected to a MongoDB replica set and have accessed a
274
+ database
275
+ <https://mongodb.github.io/mongo-swift-driver/MongoSwift/Classes/MongoClient.html>`__
276
+ that contains an ``inventory`` collection.
277
+
278
+ .. literalinclude:: /driver-examples/swiftAsync.swift
279
+ :language: swift
280
+ :dedent: 8
281
+ :start-after: Start Changestream Example 1
282
+ :end-before: End Changestream Example 1
283
+
284
+
253
285
To retrieve the :ref:`data change event <change-stream-output>` from
254
286
the cursor, iterate the change stream cursor. For information on the
255
287
change stream event, see :ref:`change-stream-output`.
@@ -396,6 +428,29 @@ Modify Change Stream Output
396
428
:start-after: Start Changestream Example 4
397
429
:end-before: End Changestream Example 4
398
430
431
+ - id: swift-sync
432
+ content: |
433
+
434
+ .. include:: /includes/fact-change-streams-modify-output.rst
435
+
436
+ .. literalinclude:: /driver-examples/swiftSync.swift
437
+ :language: swift
438
+ :dedent: 8
439
+ :start-after: Start Changestream Example 4
440
+ :end-before: End Changestream Example 4
441
+
442
+ - id: swift-async
443
+ content: |
444
+
445
+ .. include:: /includes/fact-change-streams-modify-output.rst
446
+
447
+ .. literalinclude:: /driver-examples/swiftAsync.swift
448
+ :language: swift
449
+ :dedent: 8
450
+ :start-after: Start Changestream Example 4
451
+ :end-before: End Changestream Example 4
452
+
453
+
399
454
.. tip::
400
455
401
456
The :ref:`_id <change-stream-event-id>` field of the change stream
@@ -586,6 +641,34 @@ Lookup Full Document for Update Operations
586
641
:start-after: Start Changestream Example 2
587
642
:end-before: End Changestream Example 2
588
643
644
+ - id: swift-sync
645
+ content: |
646
+
647
+ To return the most current majority-committed version of
648
+ the updated document, pass ``options:
649
+ ChangeStreamOptions(fullDocument: .updateLookup)`` to the
650
+ ``watch()`` method.
651
+
652
+ .. literalinclude:: /driver-examples/swiftSync.swift
653
+ :language: swift
654
+ :dedent: 8
655
+ :start-after: Start Changestream Example 2
656
+ :end-before: End Changestream Example 2
657
+
658
+ - id: swift-async
659
+ content: |
660
+
661
+ To return the most current majority-committed version of
662
+ the updated document, pass ``options:
663
+ ChangeStreamOptions(fullDocument: .updateLookup)`` to the
664
+ ``watch()`` method.
665
+
666
+ .. literalinclude:: /driver-examples/swiftAsync.swift
667
+ :language: swift
668
+ :dedent: 8
669
+ :start-after: Start Changestream Example 2
670
+ :end-before: End Changestream Example 2
671
+
589
672
.. note::
590
673
591
674
If there are one or more majority-committed operations that modified
@@ -782,6 +865,36 @@ Change streams are resumable by specifying a resume token to either
782
865
:start-after: Start Changestream Example 3
783
866
:end-before: End Changestream Example 3
784
867
868
+ - id: swift-sync
869
+ content: |
870
+
871
+ You can use the ``resumeAfter`` option to resume
872
+ notifications after the operation specified in the resume
873
+ token. The ``resumeAfter`` option takes a value that must
874
+ resolve to a resume token, e.g. ``resumeToken`` in the
875
+ example below.
876
+
877
+ .. literalinclude:: /driver-examples/swiftSync.swift
878
+ :language: swift
879
+ :dedent: 8
880
+ :start-after: Start Changestream Example 3
881
+ :end-before: End Changestream Example 3
882
+
883
+ - id: swift-async
884
+ content: |
885
+
886
+ You can use the ``resumeAfter`` option to resume
887
+ notifications after the operation specified in the resume
888
+ token. The ``resumeAfter`` option takes a value that must
889
+ resolve to a resume token, e.g. ``resumeToken`` in the
890
+ example below.
891
+
892
+ .. literalinclude:: /driver-examples/swiftAsync.swift
893
+ :language: swift
894
+ :dedent: 8
895
+ :start-after: Start Changestream Example 3
896
+ :end-before: End Changestream Example 3
897
+
785
898
.. _change-stream-start-after:
786
899
787
900
``startAfter`` for Change Streams
0 commit comments