Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 39 and 311]

(no description)

File Size: 442 lines (17 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: Watch  - X-Ref

Operation for creating a change stream with the aggregate command.

Note: the implementation of CommandSubscriber is an internal implementation
detail and should not be considered part of the public API.

__construct(Manager $manager, $databaseName, $collectionName, array $pipeline, array $options = [])   X-Ref
Constructs an aggregate command for creating a change stream.

Supported options:

* batchSize (integer): The number of documents to return per batch.

* collation (document): Specifies a collation.

* fullDocument (string): Determines whether the "fullDocument" field
will be populated for update operations. By default, change streams
only return the delta of fields during the update operation (via the
"updateDescription" field). To additionally return the most current
majority-committed version of the updated document, specify
"updateLookup" for this option. Defaults to "default".

Insert and replace operations always include the "fullDocument" field
and delete operations omit the field as the document no longer exists.

* maxAwaitTimeMS (integer): The maximum amount of time for the server to
wait on new documents to satisfy a change stream query.

* readConcern (MongoDB\Driver\ReadConcern): Read concern.

* readPreference (MongoDB\Driver\ReadPreference): Read preference. This
will be used to select a new server when resuming. Defaults to a
"primary" read preference.

* resumeAfter (document): Specifies the logical starting point for the
new change stream.

Using this option in conjunction with "startAfter" and/or
"startAtOperationTime" will result in a server error. The options are
mutually exclusive.

* session (MongoDB\Driver\Session): Client session.

Sessions are not supported for server versions < 3.6.

* startAfter (document): Specifies the logical starting point for the
new change stream. Unlike "resumeAfter", this option can be used with
a resume token from an "invalidate" event.

Using this option in conjunction with "resumeAfter" and/or
"startAtOperationTime" will result in a server error. The options are
mutually exclusive.

* startAtOperationTime (MongoDB\BSON\TimestampInterface): If specified,
the change stream will only provide changes that occurred at or after
the specified timestamp. Any command run against the server will
return an operation time that can be used here. Alternatively, an
operation time may be obtained from MongoDB\Driver\Server::getInfo().

Using this option in conjunction with "resumeAfter" and/or
"startAfter" will result in a server error. The options are mutually
exclusive.

This option is not supported for server versions < 4.0.

* typeMap (array): Type map for BSON deserialization. This will be
applied to the returned Cursor (it is not sent to the server).

Note: A database-level change stream may be created by specifying null
for the collection name. A cluster-level change stream may be created by
specifying null for both the database and collection name.

param: Manager     $manager        Manager instance from the driver
param: string|null $databaseName   Database name
param: string|null $collectionName Collection name
param: array       $pipeline       List of pipeline operations
param: array       $options        Command options

commandFailed(CommandFailedEvent $event)   X-Ref
No description

commandStarted(CommandStartedEvent $event)   X-Ref
No description

commandSucceeded(CommandSucceededEvent $event)   X-Ref
No description

execute(Server $server)   X-Ref
Execute the operation.

param: Server $server
return: ChangeStream

createAggregate()   X-Ref
No description

createChangeStreamIterator(Server $server)   X-Ref
Create a ChangeStreamIterator by executing the aggregate command.

param: Server $server
return: ChangeStreamIterator

executeAggregate(Server $server)   X-Ref
Execute the aggregate command.

The command will be executed using APM so that we can capture data from
its response (e.g. firstBatch size, postBatchResumeToken).

param: Server $server
return: Cursor

getInitialResumeToken()   X-Ref
Return the initial resume token for creating the ChangeStreamIterator.

return: array|object|null

resume($resumeToken = null, $hasAdvanced = false)   X-Ref
Resumes a change stream.

param: array|object|null $resumeToken
param: bool              $hasAdvanced
return: ChangeStreamIterator

shouldCaptureOperationTime(Server $server)   X-Ref
Determine whether to capture operation time from an aggregate response.

param: Server $server
return: boolean