Skip to content

Commit

Permalink
DRIVERS-1975: Add showExpandedEvents flag and new change stream eve…
Browse files Browse the repository at this point in the history
…nts (#1220)
  • Loading branch information
baileympearson committed May 31, 2022
1 parent c51e737 commit 9652564
Show file tree
Hide file tree
Showing 3 changed files with 872 additions and 7 deletions.
77 changes: 70 additions & 7 deletions source/change-streams/change-streams.rst
Expand Up @@ -9,8 +9,8 @@ Change Streams
:Status: Accepted
:Type: Standards
:Minimum Server Version: 3.6
:Last Modified: 2022-05-17
:Version: 1.15
:Last Modified: 2022-05-19
:Version: 1.16

.. contents::

Expand Down Expand Up @@ -137,7 +137,21 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
* MUST NOT err when they encounter a new `operationType`. Unknown `operationType`
* values may be represented by "unknown" or the literal string value.
*/
operationType: "insert" | "update" | "replace" | "delete" | "invalidate" | "drop" | "dropDatabase" | "rename";
operationType: "insert"
| "update"
| "replace"
| "delete"
| "invalidate"
| "drop"
| "dropDatabase"
| "rename"
| "createIndexes"
| "dropIndexes"
| "modify"
| "create"
| "shardCollection"
| "refineCollectionShardKey"
| "reshardCollection";
/**
* Contains two fields: "db" and "coll" containing the database and
Expand All @@ -155,6 +169,16 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
*/
to: Optional<Document>;
/**
* Only present for ops of type 'rename', 'create', 'modify', 'createIndexes', 'dropIndexes', 'shardCollection', 'reshardCollection', 'refineCollectionShardKey'.
* Only present when the `showExpandedEvents` change stream option is enabled.
*
* A description of the operation.
*
* @since 6.0.0
*/
operationDescription: Optional<Document>
/**
* Only present for ops of type ‘insert’, ‘update’, ‘replace’, and
* ‘delete’.
Expand All @@ -168,9 +192,6 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
/**
* Only present for ops of type ‘update’.
*
* Contains a description of updated and removed fields in this
* operation.
*/
updateDescription: Optional<UpdateDescription>;
Expand Down Expand Up @@ -208,7 +229,29 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
* The wall time from the mongod that the change event originated from.
* Populated for server versions 6.0 and above.
*/
wallTime: Optional<Datetime>;
wallTime: Optional<DateTime>;
/**
* The `ui` field from the oplog entry corresponding to the change event.
*
* Only present when the `showExpandedEvents` change stream option is enabled and for the following events
* - 'insert'
* - 'update'
* - 'delete'
* - 'createIndexes'
* - 'dropIndexes'
* - 'modify'
* - 'drop'
* - 'create'
* - 'shardCollection'
* - 'reshardCollection'
* - 'refineCollectionShardKey'
*
* This field is a value of binary subtype 4 (UUID).
*
* @since 6.0.0
*/
collectionUUID: Optional<Binary>;
}
class UpdateDescription {
Expand Down Expand Up @@ -496,6 +539,24 @@ Driver API
* @note this is an aggregation command option
*/
comment: Optional<any>
/**
* Enables the server to send the 'expanded' list of change stream events.
* The list of additional events included with this flag set are
* - createIndexes
* - dropIndexes
* - modify
* - create
* - shardCollection
* - reshardCollection
* - refineCollectionShardKey
*
* This flag is available in server versions greater than 6.0.0. `reshardCollection` and
* `refineCollectionShardKey` events are not available until server version 6.1.0.
*
* @note this is an option of the change stream pipeline stage
*/
showExpandedEvents: Optional<Boolean>
}
**NOTE:** The set of ``ChangeStreamOptions`` may grow over time.
Expand Down Expand Up @@ -1007,3 +1068,5 @@ Changelog
+------------+------------------------------------------------------------+
| 2022-05-17 | Added ``wallTime`` to ``ChangeStreamDocument``. |
+------------+------------------------------------------------------------+
| 2022-05-19 | Support new change stream events with showExpandedEvents. |
+------------+------------------------------------------------------------+

0 comments on commit 9652564

Please sign in to comment.