Skip to content

Commit 5c54082

Browse files
authored
Add ChangeStream documentation (#439)
* Add ChangeStream documentation
1 parent 02fdcff commit 5c54082

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
source:
2+
file: apiargs-MongoDBCollection-method-aggregate-option.yaml
3+
ref: batchSize
4+
---
5+
source:
6+
file: apiargs-MongoDBCollection-common-option.yaml
7+
ref: collation
8+
---
9+
arg_name: option
10+
name: fullDocument
11+
type: string
12+
description: |
13+
Allowed values are 'default' and 'updateLookup'. Defaults to 'default'.
14+
When set to 'updateLookup', the change notification for partial updates will
15+
include both a delta describing the changes to the document, as well as a
16+
copy of the entire document that was changed from some time after the change
17+
occurred. The following values are supported:
18+
19+
- ``MongoDB\Operation\ChangeStream::FULL_DOCUMENT_DEFAULT`` (*default*)
20+
- ``MongoDB\Operation\ChangeStream::FULL_DOCUMENT_UPDATE_LOOKUP``
21+
interface: phpmethod
22+
operation: ~
23+
optional: true
24+
---
25+
source:
26+
file: apiargs-MongoDBCollection-method-find-option.yaml
27+
ref: maxAwaitTimeMS
28+
---
29+
arg_name: option
30+
name: readPreference
31+
type: :php:`MongoDB\\Driver\\ReadPreference <class.mongodb-driver-readpreference>`
32+
description: |
33+
The read preference for the initial change stream aggregation, used for
34+
server selection during an automatic resume.
35+
interface: phpmethod
36+
operation: ~
37+
optional: true
38+
---
39+
arg_name: option
40+
name: resumeAfter
41+
type: array|object
42+
description: |
43+
Specifies the logical starting point for the new change stream.
44+
45+
Note this is an option of the '$changeStream' pipeline stage.
46+
interface: phpmethod
47+
operation: ~
48+
optional: true
49+
...
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arg_name: param
2+
name: $pipeline
3+
type: array|object
4+
description: |
5+
The pipeline of stages to append to an initial ``$changeStream`` stage.
6+
interface: phpmethod
7+
operation: ~
8+
optional: true
9+
---
10+
source:
11+
file: apiargs-common-param.yaml
12+
ref: $options
13+
...

source/reference/class/MongoDBCollection.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ Methods
9191
/reference/method/MongoDBCollection-replaceOne
9292
/reference/method/MongoDBCollection-updateMany
9393
/reference/method/MongoDBCollection-updateOne
94+
/reference/method/MongoDBCollection-watch
9495
/reference/method/MongoDBCollection-withOptions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
================================
2+
MongoDB\\Collection::watch()
3+
================================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. phpmethod:: MongoDB\\Collection::watch()
17+
18+
Executes a :manual:`change stream </changeStreams>` operation on the
19+
collection.
20+
21+
.. code-block:: php
22+
23+
function watch(array $pipeline = [], array $options = []): MongoDB\ChangeStream
24+
25+
This method has the following parameters:
26+
27+
.. include:: /includes/apiargs/MongoDBCollection-method-watch-param.rst
28+
29+
The ``$options`` parameter supports the following options:
30+
31+
.. include:: /includes/apiargs/MongoDBCollection-method-watch-option.rst
32+
33+
Return Values
34+
-------------
35+
36+
A :phpclass:`MongoDB\\ChangeStream` object, which allows for iteration of
37+
events in the change stream via the :php:`Iterator <class.iterator>` interface.
38+
39+
Errors/Exceptions
40+
-----------------
41+
42+
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
43+
.. include:: /includes/extracts/error-unsupportedexception.rst
44+
.. include:: /includes/extracts/error-invalidargumentexception.rst
45+
.. include:: /includes/extracts/error-driver-runtimeexception.rst
46+
47+
See Also
48+
--------
49+
50+
- :manual:`Aggregation Pipeline </core/aggregation-pipeline>` documentation in
51+
the MongoDB Manual
52+
- :manual:`Change Streams </changeStreams>` documentation in the MongoDB manual

0 commit comments

Comments
 (0)