@@ -447,7 +447,7 @@ def _fix_outgoing(self, son, collection):
447
447
448
448
def watch (self , pipeline = None , full_document = 'default' , resume_after = None ,
449
449
max_await_time_ms = None , batch_size = None , collation = None ,
450
- start_at_operation_time = None , session = None ):
450
+ start_at_operation_time = None , session = None , start_after = None ):
451
451
"""Watch changes on this database.
452
452
453
453
Performs an aggregation with an implicit initial ``$changeStream``
@@ -499,8 +499,10 @@ def watch(self, pipeline=None, full_document='default', resume_after=None,
499
499
updates will include both a delta describing the changes to the
500
500
document, as well as a copy of the entire document that was
501
501
changed from some time after the change occurred.
502
- - `resume_after` (optional): The logical starting point for this
503
- change stream.
502
+ - `resume_after` (optional): A resume token. If provided, the
503
+ change stream will start returning changes that occur directly
504
+ after the operation specified in the resume token. A resume token
505
+ is the _id value of a change document.
504
506
- `max_await_time_ms` (optional): The maximum time in milliseconds
505
507
for the server to wait for changes before responding to a getMore
506
508
operation.
@@ -514,10 +516,16 @@ def watch(self, pipeline=None, full_document='default', resume_after=None,
514
516
MongoDB >= 4.0.
515
517
- `session` (optional): a
516
518
:class:`~pymongo.client_session.ClientSession`.
519
+ - `start_after` (optional): The same as `resume_after` except that
520
+ `start_after` can resume notifications after an invalidate event.
521
+ This option and `resume_after` are mutually exclusive.
517
522
518
523
:Returns:
519
524
A :class:`~pymongo.change_stream.DatabaseChangeStream` cursor.
520
525
526
+ .. versionchanged:: 3.9
527
+ Added the ``start_after`` parameter.
528
+
521
529
.. versionadded:: 3.7
522
530
523
531
.. mongodoc:: changeStreams
@@ -527,8 +535,8 @@ def watch(self, pipeline=None, full_document='default', resume_after=None,
527
535
"""
528
536
return DatabaseChangeStream (
529
537
self , pipeline , full_document , resume_after , max_await_time_ms ,
530
- batch_size , collation , start_at_operation_time , session
531
- )
538
+ batch_size , collation , start_at_operation_time , session ,
539
+ start_after )
532
540
533
541
def _command (self , sock_info , command , slave_ok = False , value = 1 , check = True ,
534
542
allowable_errors = None , read_preference = ReadPreference .PRIMARY ,
0 commit comments