Skip to content

Commit eff48f1

Browse files
mungitoperritojeff-allen-mongo
authored andcommitted
DOCSP-18486 decode a resume token
1 parent 0b759ce commit eff48f1

File tree

5 files changed

+58
-20
lines changed

5 files changed

+58
-20
lines changed

source/changeStreams.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Change Streams
1717
:description: MongoDB triggers, change streams, database triggers, real time
1818
:keywords: MongoDB triggers, change streams, database triggers, real time
1919

20-
.. versionadded:: 3.6
21-
2220
Change streams allow applications to access real-time data changes
2321
without the complexity and risk of tailing the :term:`oplog`.
2422
Applications can use change streams to subscribe to all data changes on
@@ -953,13 +951,17 @@ The ``_id`` value of a :ref:`change stream event document
953951
"_data" : <BinData|hex string>
954952
}
955953

954+
.. tip::
955+
956+
.. include:: /includes/extracts/4.2-changes-change-stream-modification-error.rst
957+
956958
.. include:: /includes/extracts/changestream-resume-token-versions-4.2-greater.rst
957959

958960
.. include:: /includes/extracts/changestream-resume-token-hex-change.rst
959961

960962
.. tip::
961963

962-
.. include:: /includes/extracts/4.2-changes-change-stream-modification-error.rst
964+
.. include:: /includes/note-decode-resume-tokens.rst
963965

964966
Use Cases
965967
---------
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
MongoDB provides a :ref:`"snippet" <snip-overview>`, an
2+
extension to :binary:`~bin.mongosh`, that decodes hex-encoded
3+
resume tokens.
4+
5+
You can install and run the `resumetoken
6+
<https://github.com/mongodb-labs/mongosh-snippets/tree/main/snippets/resumetoken>`__
7+
snippet from :binary:`~bin.mongosh`:
8+
9+
.. code-block:: javascript
10+
11+
snippet install resumetoken
12+
decodeResumeToken('<RESUME TOKEN>')
13+
14+
You can also run `resumetoken
15+
<https://github.com/mongodb-labs/mongosh-snippets/tree/main/snippets/resumetoken>`__
16+
from the command line (without using :binary:`~bin.mongosh`) if ``npm``
17+
is installed on your system:
18+
19+
.. code-block:: javascript
20+
21+
npx mongodb-resumetoken-decoder <RESUME TOKEN>
22+
23+
See the following for more details on:
24+
25+
- `resumetoken
26+
<https://github.com/mongodb-labs/mongosh-snippets/tree/main/snippets/resumetoken>`__
27+
- :ref:`using snippets <snip-using-snippets>` in :binary:`~bin.mongosh`.
28+

source/reference/method/Mongo.watch.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,16 @@ Resumability
239239

240240
.. include:: /includes/extracts/changestream-resume-token-versions-4.2-greater.rst
241241

242+
Hex Encoded Tokens
243+
``````````````````
244+
242245
.. include:: /includes/extracts/changestream-resume-token-hex-change.rst
243246

247+
Decode Resume Tokens
248+
````````````````````
249+
250+
.. include:: /includes/note-decode-resume-tokens.rst
251+
244252
Full Document Lookup of Update Operations
245253
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246254

source/reference/method/db.collection.watch.txt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,9 @@ Definition
6060
You must pass an empty array ``[]`` to the ``pipeline`` parameter if
6161
you are not specifying a pipeline but are passing the ``options``
6262
document.
63-
64-
65-
66-
6763

6864
The ``options`` document can contain the following fields and values:
6965

70-
7166
.. list-table::
7267
:header-rows: 1
7368
:widths: 20 20 80
@@ -178,15 +173,8 @@ Definition
178173

179174
``startAtOperationTime`` is mutually exclusive with ``resumeAfter``
180175
and ``startAfter``.
181-
182-
183-
184-
.. versionadded:: 4.0
185-
186-
187-
188-
189176

177+
.. versionadded:: 4.0
190178

191179
:returns:
192180
A :term:`cursor` that remains open as long as a connection to the
@@ -242,8 +230,16 @@ Resumability
242230

243231
.. include:: /includes/extracts/changestream-resume-token-versions-4.2-greater.rst
244232

233+
Hex Encoded Tokens
234+
``````````````````
235+
245236
.. include:: /includes/extracts/changestream-resume-token-hex-change.rst
246237

238+
Decode Resume Tokens
239+
````````````````````
240+
241+
.. include:: /includes/note-decode-resume-tokens.rst
242+
247243
.. |watchmethod| replace:: :method:`db.collection.watch()`
248244

249245

source/reference/method/db.watch.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ Definition
178178

179179
``startAtOperationTime`` is mutually exclusive with ``resumeAfter``
180180
and ``startAfter``.
181-
182-
183-
184-
185181

186182
:returns:
187183
A :term:`cursor` over the change event documents.
@@ -243,8 +239,16 @@ Resumability
243239

244240
.. include:: /includes/extracts/changestream-resume-token-versions-4.2-greater.rst
245241

242+
Hex Encoded Tokens
243+
``````````````````
244+
246245
.. include:: /includes/extracts/changestream-resume-token-hex-change.rst
247246

247+
Decode Resume Tokens
248+
````````````````````
249+
250+
.. include:: /includes/note-decode-resume-tokens.rst
251+
248252
.. |watchmethod| replace:: :method:`db.watch()`
249253

250254
Full Document Lookup of Update Operations

0 commit comments

Comments
 (0)