Interface ChangeStreamReplaceDocument<TSchema>

interface ChangeStreamReplaceDocument<TSchema> {
    _id: unknown;
    clusterTime?: Timestamp;
    documentKey: {
        _id: InferIdType<TSchema>;
        [shardKey: string]: any;
    };
    fullDocument: TSchema;
    fullDocumentBeforeChange?: TSchema;
    lsid?: ServerSessionId;
    ns: ChangeStreamNameSpace;
    operationType: "replace";
    splitEvent?: ChangeStreamSplitEvent;
    txnNumber?: number;
}

Type Parameters

Hierarchy (view full)

Properties

_id: unknown

The id functions as an opaque token for use when resuming an interrupted change stream.

clusterTime?: Timestamp

The timestamp from the oplog entry associated with the event. For events that happened as part of a multi-document transaction, the associated change stream notifications will have the same clusterTime value, namely the time when the transaction was committed. On a sharded cluster, events that occur on different shards can have the same clusterTime but be associated with different transactions or even not be associated with any transaction. To identify events for a single transaction, you can use the combination of lsid and txnNumber in the change stream event document.

documentKey: {
    _id: InferIdType<TSchema>;
    [shardKey: string]: any;
}

For unsharded collections this contains a single field _id. For sharded collections, this will contain all the components of the shard key

fullDocument: TSchema

The fullDocument of a replace event represents the document after the insert of the replacement document

fullDocumentBeforeChange?: TSchema

Contains the pre-image of the modified or deleted document if the pre-image is available for the change event and either 'required' or 'whenAvailable' was specified for the 'fullDocumentBeforeChange' option when creating the change stream. If 'whenAvailable' was specified but the pre-image is unavailable, this will be explicitly set to null.

The identifier for the session associated with the transaction. Only present if the operation is part of a multi-document transaction.

Namespace the replace event occurred on

operationType: "replace"

Describes the type of operation represented in this change notification

When the change stream's backing aggregation pipeline contains the $changeStreamSplitLargeEvent stage, events larger than 16MB will be split into multiple events and contain the following information about which fragment the current event is.

txnNumber?: number

The transaction number. Only present if the operation is part of a multi-document transaction.

NOTE: txnNumber can be a Long if promoteLongs is set to false