Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
|
Public Member Functions | |
__construct (Manager $manager, ?string $databaseName, ?string $collectionName, array $pipeline, array $options=[]) | |
Constructs an aggregate command for creating a change stream. | |
commandFailed (CommandFailedEvent $event) | |
commandStarted (CommandStartedEvent $event) | |
commandSucceeded (CommandSucceededEvent $event) | |
execute (Server $server) | |
Execute the operation. | |
MongoDB\Operation\Watch::__construct | ( | Manager | $manager, |
?string | $databaseName, | ||
?string | $collectionName, | ||
array | $pipeline, | ||
array | $options = [] ) |
Constructs an aggregate command for creating a change stream.
Supported options:
comment (mixed): BSON value to attach as a comment to this command.
Only string values are supported for server versions < 4.4.
fullDocument (string): Determines how the "fullDocument" response field will be populated for update operations.
By default, change streams only return the delta of fields (via an "updateDescription" field) for update operations and "fullDocument" is omitted. Insert and replace operations always include the "fullDocument" field. Delete operations omit the field as the document no longer exists.
Specify "updateLookup" to return the current majority-committed version of the updated document.
MongoDB 6.0+ allows returning the post-image of the modified document if the collection has changeStreamPreAndPostImages enabled. Specify "whenAvailable" to return the post-image if available or a null value if not. Specify "required" to return the post-image if available or raise an error if not.
fullDocumentBeforeChange (string): Determines how the "fullDocumentBeforeChange" response field will be populated. By default, the field is omitted.
MongoDB 6.0+ allows returning the pre-image of the modified document if the collection has changeStreamPreAndPostImages enabled. Specify "whenAvailable" to return the pre-image if available or a null value if not. Specify "required" to return the pre-image if available or raise an error if not.
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.
showExpandedEvents (boolean): Enables the server to send the expanded list of change stream events.
This option is not supported for server versions < 6.0.
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.
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.
Manager | $manager | Manager instance from the driver |
string | null | $databaseName | Database name |
string | null | $collectionName | Collection name |
array | $pipeline | List of pipeline operations |
array | $options | Command options |
InvalidArgumentException | for parameter/option parsing errors |
MongoDB\Operation\Watch::execute | ( | Server | $server | ) |
Execute the operation.
ChangeStream |
UnsupportedException | if collation or read concern is used and unsupported |
RuntimeException | for other driver errors (e.g. connection errors) |
Implements MongoDB\Operation\Executable.