Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
13a2f7f6
Commit
13a2f7f6
authored
Jul 16, 2019
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-435: Document ChangeStream::getResumeToken()
parent
e651f9ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
MongoDBChangeStream-getResumeToken.txt
docs/reference/method/MongoDBChangeStream-getResumeToken.txt
+75
-0
result-classes.txt
docs/reference/result-classes.txt
+1
-0
No files found.
docs/reference/method/MongoDBChangeStream-getResumeToken.txt
0 → 100644
View file @
13a2f7f6
=======================================
MongoDB\\ChangeStream::getResumeToken()
=======================================
.. versionadded:: 1.5
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\ChangeStream::getResumeToken()
Returns the cached resume token that will be used to resume the change
stream.
.. code-block:: php
function getResumeToken(): array|object|null
Return Values
-------------
An array or object, or ``null`` if there is no cached resume token. The return
type will depend on the ``typeMap`` option for the ``watch()`` method used to
create the change stream.
Examples
--------
This example captures the resume token for a change stream after encountering
an ``invalidate`` event and uses it to construct a second change stream using
the ``startAfter`` option.
.. code-block:: php
<?php
$uri = 'mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet';
$collection = (new MongoDB\Client($uri))->test->inventory;
$changeStream = $collection->watch();
for ($changeStream->rewind(); true; $changeStream->next()) {
if ( ! $changeStream->valid()) {
continue;
}
$event = $changeStream->current();
if ($event['operationType'] === 'invalidate') {
$startAfter = $changeStream->getResumeToken();
break;
}
printf("%d: %s\n", $changeStream->key(), $event['operationType']);
}
$changeStream = $collection->watch([], ['startAfter' => $startAfter]);
See Also
--------
- :phpmethod:`MongoDB\\Client::watch()`
- :phpmethod:`MongoDB\\Collection::watch()`
- :phpmethod:`MongoDB\\Database::watch()`
- :manual:`Resume a Change Stream </changeStreams#resume-a-change-stream>`
documentation in the MongoDB manual
docs/reference/result-classes.txt
View file @
13a2f7f6
...
...
@@ -36,6 +36,7 @@ Methods
/reference/method/MongoDBChangeStream-current
/reference/method/MongoDBChangeStream-getCursorId
/reference/method/MongoDBChangeStream-getResumeToken
/reference/method/MongoDBChangeStream-key
/reference/method/MongoDBChangeStream-next
/reference/method/MongoDBChangeStream-rewind
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment