Class ChangeStreamDocument<TDocument>
- Type Parameters:
TDocument
- The type that this collection will encode thefullDocument
field into.
$changeStream
aggregation output document.
Note: this class will not be applicable for all change stream outputs. If using custom pipelines that radically change the change stream result, then an alternative document format should be used.
- Since:
- 3.6
-
Constructor Summary
ConstructorDescriptionChangeStreamDocument
(OperationType operationType, BsonDocument resumeToken, BsonDocument namespaceDocument, BsonDocument destinationNamespaceDocument, TDocument fullDocument, BsonDocument documentKey, BsonTimestamp clusterTime, UpdateDescription updateDescription, BsonInt64 txnNumber, BsonDocument lsid) Deprecated.ChangeStreamDocument
(String operationTypeString, BsonDocument resumeToken, BsonDocument namespaceDocument, BsonDocument destinationNamespaceDocument, TDocument fullDocument, BsonDocument documentKey, BsonTimestamp clusterTime, UpdateDescription updateDescription, BsonInt64 txnNumber, BsonDocument lsid) Deprecated.ChangeStreamDocument
(String operationTypeString, BsonDocument resumeToken, BsonDocument namespaceDocument, BsonDocument destinationNamespaceDocument, TDocument fullDocument, TDocument fullDocumentBeforeChange, BsonDocument documentKey, BsonTimestamp clusterTime, UpdateDescription updateDescription, BsonInt64 txnNumber, BsonDocument lsid, BsonDateTime wallTime, SplitEvent splitEvent, BsonDocument extraElements) Creates a new instanceChangeStreamDocument
(String operationTypeString, BsonDocument resumeToken, BsonDocument namespaceDocument, BsonDocument destinationNamespaceDocument, TDocument fullDocument, TDocument fullDocumentBeforeChange, BsonDocument documentKey, BsonTimestamp clusterTime, UpdateDescription updateDescription, BsonInt64 txnNumber, BsonDocument lsid, BsonDateTime wallTime, BsonDocument extraElements) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic <TFullDocument>
Codec<ChangeStreamDocument<TFullDocument>>createCodec
(Class<TFullDocument> fullDocumentClass, CodecRegistry codecRegistry) Creates the codec for the specific ChangeStreamOutput typeboolean
Gets the cluster time at which the change occurred.Returns the database nameReturns the destination namespace, derived from the "to" field in a change stream document.Returns the destination namespace document, derived from the "to" field in a change stream document.Returns a document containing just the _id of the changed document.Any extra elements that are part of the change stream document but not otherwise mapped to fields.Returns the fullDocument.Returns the fullDocument before changegetLsid()
Returns the identifier for the session associated with the transactionReturns the namespace, derived from the "ns" field in a change stream document.Returns the namespace document, derived from the "ns" field in a change stream document.Returns the operationType.Returns the operation type as a string.Returns the resumeTokenThe split event.Returns the transaction numberReturns the updateDescriptionThe wall time of the server at the moment the change occurred.int
hashCode()
toString()
-
Constructor Details
-
ChangeStreamDocument
public ChangeStreamDocument(@Nullable @BsonProperty("operationType") String operationTypeString, @BsonProperty("resumeToken") BsonDocument resumeToken, @Nullable @BsonProperty("ns") BsonDocument namespaceDocument, @Nullable @BsonProperty("to") BsonDocument destinationNamespaceDocument, @Nullable @BsonProperty("fullDocument") TDocument fullDocument, @Nullable @BsonProperty("fullDocumentBeforeChange") TDocument fullDocumentBeforeChange, @Nullable @BsonProperty("documentKey") BsonDocument documentKey, @Nullable @BsonProperty("clusterTime") BsonTimestamp clusterTime, @Nullable @BsonProperty("updateDescription") UpdateDescription updateDescription, @Nullable @BsonProperty("txnNumber") BsonInt64 txnNumber, @Nullable @BsonProperty("lsid") BsonDocument lsid, @Nullable @BsonProperty("wallTime") BsonDateTime wallTime, @Nullable @BsonProperty("splitEvent") SplitEvent splitEvent, @Nullable @BsonProperty BsonDocument extraElements) Creates a new instance- Parameters:
operationTypeString
- the operation typeresumeToken
- the resume tokennamespaceDocument
- the BsonDocument representing the namespacedestinationNamespaceDocument
- the BsonDocument representing the destinatation namespacefullDocument
- the full documentfullDocumentBeforeChange
- the full document before changedocumentKey
- a document containing the _id of the changed documentclusterTime
- the cluster time at which the change occuredupdateDescription
- the update descriptiontxnNumber
- the transaction numberlsid
- the identifier for the session associated with the transactionwallTime
- the wall time of the server at the moment the change occurredsplitEvent
- the split eventextraElements
- any extra elements that are part of the change stream document but not otherwise mapped to fields- Since:
- 4.11
-
ChangeStreamDocument
@Deprecated public ChangeStreamDocument(@BsonProperty("operationType") String operationTypeString, @BsonProperty("resumeToken") BsonDocument resumeToken, @Nullable @BsonProperty("ns") BsonDocument namespaceDocument, @Nullable @BsonProperty("to") BsonDocument destinationNamespaceDocument, @Nullable @BsonProperty("fullDocument") TDocument fullDocument, @Nullable @BsonProperty("fullDocumentBeforeChange") TDocument fullDocumentBeforeChange, @Nullable @BsonProperty("documentKey") BsonDocument documentKey, @Nullable @BsonProperty("clusterTime") BsonTimestamp clusterTime, @Nullable @BsonProperty("updateDescription") UpdateDescription updateDescription, @Nullable @BsonProperty("txnNumber") BsonInt64 txnNumber, @Nullable @BsonProperty("lsid") BsonDocument lsid, @Nullable @BsonProperty("wallTime") BsonDateTime wallTime, @Nullable @BsonProperty BsonDocument extraElements) Deprecated.Creates a new instance- Parameters:
operationTypeString
- the operation typeresumeToken
- the resume tokennamespaceDocument
- the BsonDocument representing the namespacedestinationNamespaceDocument
- the BsonDocument representing the destinatation namespacefullDocument
- the full documentfullDocumentBeforeChange
- the full document before changedocumentKey
- a document containing the _id of the changed documentclusterTime
- the cluster time at which the change occuredupdateDescription
- the update descriptiontxnNumber
- the transaction numberlsid
- the identifier for the session associated with the transactionwallTime
- the wall time of the server at the moment the change occurredextraElements
- any extra elements that are part of the change stream document but not otherwise mapped to fields- Since:
- 4.7
-
ChangeStreamDocument
@Deprecated public ChangeStreamDocument(@BsonProperty("operationType") String operationTypeString, @BsonProperty("resumeToken") BsonDocument resumeToken, @Nullable @BsonProperty("ns") BsonDocument namespaceDocument, @Nullable @BsonProperty("to") BsonDocument destinationNamespaceDocument, @Nullable @BsonProperty("fullDocument") TDocument fullDocument, @Nullable @BsonProperty("documentKey") BsonDocument documentKey, @Nullable @BsonProperty("clusterTime") BsonTimestamp clusterTime, @Nullable @BsonProperty("updateDescription") UpdateDescription updateDescription, @Nullable @BsonProperty("txnNumber") BsonInt64 txnNumber, @Nullable @BsonProperty("lsid") BsonDocument lsid) Deprecated.Creates a new instance- Parameters:
operationTypeString
- the operation typeresumeToken
- the resume tokennamespaceDocument
- the BsonDocument representing the namespacedestinationNamespaceDocument
- the BsonDocument representing the destinatation namespacefullDocument
- the full documentdocumentKey
- a document containing the _id of the changed documentclusterTime
- the cluster time at which the change occuredupdateDescription
- the update descriptiontxnNumber
- the transaction numberlsid
- the identifier for the session associated with the transaction- Since:
- 4.6
-
ChangeStreamDocument
@Deprecated public ChangeStreamDocument(OperationType operationType, BsonDocument resumeToken, BsonDocument namespaceDocument, BsonDocument destinationNamespaceDocument, TDocument fullDocument, BsonDocument documentKey, BsonTimestamp clusterTime, UpdateDescription updateDescription, BsonInt64 txnNumber, BsonDocument lsid) Deprecated.Creates a new instance- Parameters:
operationType
- the operation typeresumeToken
- the resume tokennamespaceDocument
- the BsonDocument representing the namespacedestinationNamespaceDocument
- the BsonDocument representing the destinatation namespacefullDocument
- the full documentdocumentKey
- a document containing the _id of the changed documentclusterTime
- the cluster time at which the change occuredupdateDescription
- the update descriptiontxnNumber
- the transaction numberlsid
- the identifier for the session associated with the transaction- Since:
- 3.11
-
-
Method Details
-
getResumeToken
Returns the resumeToken- Returns:
- the resumeToken
-
getNamespace
Returns the namespace, derived from the "ns" field in a change stream document.The invalidate operation type does include a MongoNamespace in the ChangeStreamDocument response. The dropDatabase operation type includes a MongoNamespace, but does not include a collection name as part of the namespace.
- Returns:
- the namespace. If the namespaceDocument is null or if it is missing either the 'db' or 'coll' keys, then this will return null.
-
getNamespaceDocument
Returns the namespace document, derived from the "ns" field in a change stream document.The namespace document is a BsonDocument containing the values associated with a MongoNamespace. The 'db' key refers to the database name and the 'coll' key refers to the collection name.
- Returns:
- the namespaceDocument
- Since:
- 3.8
-
getDestinationNamespace
Returns the destination namespace, derived from the "to" field in a change stream document.The destination namespace is used to indicate the destination of a collection rename event.
- Returns:
- the namespace. If the "to" document is null or absent, then this will return null.
- Since:
- 3.11
- See Also:
-
getDestinationNamespaceDocument
Returns the destination namespace document, derived from the "to" field in a change stream document.The destination namespace document is a BsonDocument containing the values associated with a MongoNamespace. The 'db' key refers to the database name and the 'coll' key refers to the collection name.
- Returns:
- the destinationNamespaceDocument
- Since:
- 3.11
-
getDatabaseName
Returns the database name- Returns:
- the databaseName. If the namespaceDocument is null or if it is missing the 'db' key, then this will return null.
- Since:
- 3.8
-
getFullDocument
Returns the fullDocument.Always present for operations of type
OperationType.INSERT
andOperationType.REPLACE
. Also present for operations of typeOperationType.UPDATE
if the user has specifiedFullDocument.UPDATE_LOOKUP
for thefullDocument
option when creating the change stream.For operations of type
OperationType.INSERT
andOperationType.REPLACE
, the value will contain the document being inserted or the new version of the document that is replacing the existing document, respectively.For operations of type
OperationType.UPDATE
, the value will contain a copy of the full version of the document from some point after the update occurred. If the document was deleted since the updated happened, the value may be null.Contains the point-in-time post-image of the modified document if the post-image is available and either
FullDocument.REQUIRED
orFullDocument.WHEN_AVAILABLE
was specified for thefullDocument
option when creating the change stream. A post-image is always available forOperationType.INSERT
andOperationType.REPLACE
events.- Returns:
- the fullDocument
-
getFullDocumentBeforeChange
Returns the fullDocument before changeContains the pre-image of the modified or deleted document if the pre-image is available for the change event and either
FullDocumentBeforeChange.REQUIRED
orFullDocumentBeforeChange.WHEN_AVAILABLE
was specified for thefullDocumentBeforeChange
option when creating the change stream. IfFullDocumentBeforeChange.WHEN_AVAILABLE
was specified but the pre-image is unavailable, the value will be null.- Returns:
- the fulDocument before change
- Since:
- 4.7
- Since server release
- 6.0
-
getDocumentKey
Returns a document containing just the _id of the changed document.For unsharded collections this contains a single field, _id, with the value of the _id of the document updated. For sharded collections, this will contain all the components of the shard key in order, followed by the _id if the _id isn’t part of the shard key.
- Returns:
- the document key, or null if the event is not associated with a single document (e.g. a collection rename event)
-
getClusterTime
Gets the cluster time at which the change occurred.- Returns:
- the cluster time at which the change occurred
- Since:
- 3.8
- Since server release
- 4.0
-
getOperationTypeString
Returns the operation type as a string.This method is useful when using a driver release that has not yet been updated to include a newer operation type in the
OperationType
enum. In that case,getOperationType()
will returnOperationType.OTHER
and this method can be used to retrieve the actual operation type as a string value.May return null only if
$changeStreamSplitLargeEvent
is used.- Returns:
- the operation type as a string
- Since:
- 4.6
- See Also:
-
getOperationType
Returns the operationType.May return null only if
$changeStreamSplitLargeEvent
is used.- Returns:
- the operationType
-
getUpdateDescription
Returns the updateDescription- Returns:
- the updateDescription, or null if the event is not associated with a single document (e.g. a collection rename event)
-
getTxnNumber
Returns the transaction number- Returns:
- the transaction number, or null if not part of a multi-document transaction
- Since:
- 3.11
- Since server release
- 4.0
-
getLsid
Returns the identifier for the session associated with the transaction- Returns:
- the lsid, or null if not part of a multi-document transaction
- Since:
- 3.11
- Since server release
- 4.0
-
getWallTime
The wall time of the server at the moment the change occurred.- Returns:
- The wall time of the server at the moment the change occurred.
- Since:
- 4.7
- Since server release
- 6.0
-
getSplitEvent
The split event.- Returns:
- the split event
- Since:
- 4.11
- Since server release
- 6.0.9
-
getExtraElements
Any extra elements that are part of the change stream document but not otherwise mapped to fields.- Returns:
- Any extra elements that are part of the change stream document but not otherwise mapped to fields.
- Since:
- 4.7
-
createCodec
public static <TFullDocument> Codec<ChangeStreamDocument<TFullDocument>> createCodec(Class<TFullDocument> fullDocumentClass, CodecRegistry codecRegistry) Creates the codec for the specific ChangeStreamOutput type- Type Parameters:
TFullDocument
- the fullDocument type- Parameters:
fullDocumentClass
- the class to use to represent the fullDocumentcodecRegistry
- the codec registry- Returns:
- the codec
-
equals
-
hashCode
public int hashCode() -
toString
-