@@ -9,8 +9,8 @@ Change Streams
99:Status: Accepted
1010:Type: Standards
1111:Minimum Server Version: 3.6
12- :Last Modified: 2022-03-25
13- :Version: 1.13.1
12+ :Last Modified: 2022-04-13
13+ :Version: 1.14
1414
1515.. contents ::
1616
@@ -175,20 +175,34 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
175175 updateDescription: Optional <UpdateDescription >;
176176
177177 /**
178- * Always present for operations of type ‘insert’ and ‘replace’. Also
179- * present for operations of type ‘update’ if the user has specified ‘updateLookup’
180- * in the ‘fullDocument’ arguments to the ‘$changeStream’ stage.
178+ * Always present for operations of type 'insert' and 'replace'. Also
179+ * present for operations of type 'update' if the user has specified
180+ * 'updateLookup' for the 'fullDocument' option when creating the change
181+ * stream.
181182 *
182- * For operations of type ‘ insert’ and ‘ replace’ , this key will contain the
183- * document being inserted, or the new version of the document that is replacing
184- * the existing document, respectively.
183+ * For operations of type ' insert' and ' replace' , this key will contain the
184+ * document being inserted or the new version of the document that is
185+ * replacing the existing document, respectively.
185186 *
186- * For operations of type ‘ update’ , this key will contain a copy of the full
187+ * For operations of type ' update' , this key will contain a copy of the full
187188 * version of the document from some point after the update occurred. If the
188189 * document was deleted since the updated happened, it will be null.
190+ *
191+ * Contains the point-in-time post-image of the modified document if the
192+ * post-image is available and either 'required' or 'whenAvailable' was
193+ * specified for the 'fullDocument' option when creating the change stream.
194+ * A post-image is always available for 'insert' and 'replace' events.
189195 */
190196 fullDocument: Document | null ;
191197
198+ /**
199+ * Contains the pre-image of the modified or deleted document if the
200+ * pre-image is available for the change event and either 'required' or
201+ * 'whenAvailable' was specified for the 'fullDocumentBeforeChange' option
202+ * when creating the change stream. If 'whenAvailable' was specified but the
203+ * pre-image is unavailable, this will be explicitly set to null.
204+ */
205+ fullDocumentBeforeChange: Document | null ;
192206 }
193207
194208 class UpdateDescription {
@@ -347,16 +361,52 @@ Driver API
347361
348362 class ChangeStreamOptions {
349363 /**
350- * Allowed values: ‘updateLookup’. When set to ‘updateLookup’, the change notification
351- * for partial updates will include both a delta describing the changes to the document,
352- * as well as a copy of the entire document that was changed from some time after the
353- * change occurred. The default is to not send a value.
354- * For forward compatibility, a driver MUST NOT raise an error when a user provides an
355- * unknown value. The driver relies on the server to validate this option.
364+ * Allowed values: 'default', 'updateLookup', 'whenAvailable', 'required'.
365+ *
366+ * The default is to not send a value, which is equivalent to 'default'. By
367+ * default, the change notification for partial updates will include a delta
368+ * describing the changes to the document.
369+ *
370+ * When set to 'updateLookup', the change notification for partial updates
371+ * will include both a delta describing the changes to the document as well
372+ * as a copy of the entire document that was changed from some time after
373+ * the change occurred.
374+ *
375+ * When set to 'whenAvailable', configures the change stream to return the
376+ * post-image of the modified document for replace and update change events
377+ * if the post-image for this event is available.
378+ *
379+ * When set to 'required', the same behavior as 'whenAvailable' except that
380+ * an error is raised if the post-image is not available.
381+ *
382+ * For forward compatibility, a driver MUST NOT raise an error when a user
383+ * provides an unknown value. The driver relies on the server to validate
384+ * this option.
385+ *
356386 * @note this is an option of the `$changeStream` pipeline stage.
357387 */
358388 fullDocument: Optional <String >;
359389
390+ /**
391+ * Allowed values: 'whenAvailable', 'required', 'off'.
392+ *
393+ * The default is to not send a value, which is equivalent to 'off'.
394+ *
395+ * When set to 'whenAvailable', configures the change stream to return the
396+ * pre-image of the modified document for replace, update, and delete change
397+ * events if it is available.
398+ *
399+ * When set to 'required', the same behavior as 'whenAvailable' except that
400+ * an error is raised if the pre-image is not available.
401+ *
402+ * For forward compatibility, a driver MUST NOT raise an error when a user
403+ * provides an unknown value. The driver relies on the server to validate
404+ * this option.
405+ *
406+ * @note this is an option of the `$changeStream` pipeline stage.
407+ */
408+ fullDocumentBeforeChange: Optional <String >;
409+
360410 /**
361411 * Specifies the logical starting point for the new change stream.
362412 *
@@ -946,3 +996,6 @@ Changelog
946996+------------+------------------------------------------------------------+
947997| 2022-03-25 | Do not error when parsing change stream event documents. |
948998+------------+------------------------------------------------------------+
999+ | 2022-04-13 | Support returning point-in-time pre and post-images with |
1000+ | | ``fullDocumentBeforeChange `` and ``fullDocument ``. |
1001+ +------------+------------------------------------------------------------+
0 commit comments