NewDocumentDB 1.0 is here. See what's new
MQL reference navigation

$changeStream

Important

DocumentDB does not support $changeStream. Any pipeline that uses it, including db.collection.watch(), fails with Stage $changeStream is not supported yet in native pipeline (CommandNotSupported, code 115).

In MongoDB, the $changeStream aggregation stage opens a cursor that reports inserts, updates, deletes, and other changes as they happen. The syntax below is listed for reference only.

Syntax

{
  $changeStream: {
    allChangesForCluster: <boolean>,
    fullDocument: <string>,
    fullDocumentBeforeChange: <string>,
    resumeAfter: <ResumeToken>,
    startAfter: <ResumeToken>,
    startAtOperationTime: <Timestamp>,
    showExpandedEvents: <boolean>
  }
}

Parameters

ParameterDescription
allChangesForClusterOptional. Boolean. If true, returns changes for the entire cluster. Default is false.
fullDocumentOptional. String. Determines what to return for update operations. Options: 'default', 'updateLookup', 'whenAvailable', 'required'.
fullDocumentBeforeChangeOptional. String. Returns the preimage of the document. Options: "off", "whenAvailable", "required".
resumeAfterOptional. Resume token to resume change stream after a specific event.
startAfterOptional. Resume token to start change stream after a specific event.
startAtOperationTimeOptional. timestamp for starting change stream from a specific time.
showExpandedEventsOptional. Boolean. Include another change stream events. Default is false.

Example

This pipeline is rejected:

db.stores.aggregate([
  {
    $changeStream: {
      fullDocument: "updateLookup"
    }
  }
])
Stage $changeStream is not supported yet in native pipeline