Skip to content

Commit 9652564

Browse files
DRIVERS-1975: Add showExpandedEvents flag and new change stream events (#1220)
1 parent c51e737 commit 9652564

File tree

3 files changed

+872
-7
lines changed

3 files changed

+872
-7
lines changed

source/change-streams/change-streams.rst

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Change Streams
99
:Status: Accepted
1010
:Type: Standards
1111
:Minimum Server Version: 3.6
12-
:Last Modified: 2022-05-17
13-
:Version: 1.15
12+
:Last Modified: 2022-05-19
13+
:Version: 1.16
1414

1515
.. contents::
1616

@@ -137,7 +137,21 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
137137
* MUST NOT err when they encounter a new `operationType`. Unknown `operationType`
138138
* values may be represented by "unknown" or the literal string value.
139139
*/
140-
operationType: "insert" | "update" | "replace" | "delete" | "invalidate" | "drop" | "dropDatabase" | "rename";
140+
operationType: "insert"
141+
| "update"
142+
| "replace"
143+
| "delete"
144+
| "invalidate"
145+
| "drop"
146+
| "dropDatabase"
147+
| "rename"
148+
| "createIndexes"
149+
| "dropIndexes"
150+
| "modify"
151+
| "create"
152+
| "shardCollection"
153+
| "refineCollectionShardKey"
154+
| "reshardCollection";
141155
142156
/**
143157
* Contains two fields: "db" and "coll" containing the database and
@@ -155,6 +169,16 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
155169
*/
156170
to: Optional<Document>;
157171
172+
/**
173+
* Only present for ops of type 'rename', 'create', 'modify', 'createIndexes', 'dropIndexes', 'shardCollection', 'reshardCollection', 'refineCollectionShardKey'.
174+
* Only present when the `showExpandedEvents` change stream option is enabled.
175+
*
176+
* A description of the operation.
177+
*
178+
* @since 6.0.0
179+
*/
180+
operationDescription: Optional<Document>
181+
158182
/**
159183
* Only present for ops of type ‘insert’, ‘update’, ‘replace’, and
160184
* ‘delete’.
@@ -168,9 +192,6 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
168192
169193
/**
170194
* Only present for ops of type ‘update’.
171-
*
172-
* Contains a description of updated and removed fields in this
173-
* operation.
174195
*/
175196
updateDescription: Optional<UpdateDescription>;
176197
@@ -208,7 +229,29 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
208229
* The wall time from the mongod that the change event originated from.
209230
* Populated for server versions 6.0 and above.
210231
*/
211-
wallTime: Optional<Datetime>;
232+
wallTime: Optional<DateTime>;
233+
234+
/**
235+
* The `ui` field from the oplog entry corresponding to the change event.
236+
*
237+
* Only present when the `showExpandedEvents` change stream option is enabled and for the following events
238+
* - 'insert'
239+
* - 'update'
240+
* - 'delete'
241+
* - 'createIndexes'
242+
* - 'dropIndexes'
243+
* - 'modify'
244+
* - 'drop'
245+
* - 'create'
246+
* - 'shardCollection'
247+
* - 'reshardCollection'
248+
* - 'refineCollectionShardKey'
249+
*
250+
* This field is a value of binary subtype 4 (UUID).
251+
*
252+
* @since 6.0.0
253+
*/
254+
collectionUUID: Optional<Binary>;
212255
}
213256
214257
class UpdateDescription {
@@ -496,6 +539,24 @@ Driver API
496539
* @note this is an aggregation command option
497540
*/
498541
comment: Optional<any>
542+
543+
/**
544+
* Enables the server to send the 'expanded' list of change stream events.
545+
* The list of additional events included with this flag set are
546+
* - createIndexes
547+
* - dropIndexes
548+
* - modify
549+
* - create
550+
* - shardCollection
551+
* - reshardCollection
552+
* - refineCollectionShardKey
553+
*
554+
* This flag is available in server versions greater than 6.0.0. `reshardCollection` and
555+
* `refineCollectionShardKey` events are not available until server version 6.1.0.
556+
*
557+
* @note this is an option of the change stream pipeline stage
558+
*/
559+
showExpandedEvents: Optional<Boolean>
499560
}
500561
501562
**NOTE:** The set of ``ChangeStreamOptions`` may grow over time.
@@ -1007,3 +1068,5 @@ Changelog
10071068
+------------+------------------------------------------------------------+
10081069
| 2022-05-17 | Added ``wallTime`` to ``ChangeStreamDocument``. |
10091070
+------------+------------------------------------------------------------+
1071+
| 2022-05-19 | Support new change stream events with showExpandedEvents. |
1072+
+------------+------------------------------------------------------------+

0 commit comments

Comments
 (0)