Class MongoDbDataChangeEvent
Represents a data change event captured from MongoDB Change Streams.
public sealed class MongoDbDataChangeEvent
- Inheritance
-
MongoDbDataChangeEvent
- Inherited Members
Properties
ChangeType
Gets the type of change (Insert, Update, Replace, Delete, etc.).
public MongoDbDataChangeType ChangeType { get; init; }
Property Value
ClusterTime
Gets the cluster time when the change occurred.
public BsonTimestamp? ClusterTime { get; init; }
Property Value
- BsonTimestamp
CollectionName
Gets the collection name where the change occurred.
public string CollectionName { get; init; }
Property Value
DatabaseName
Gets the database name where the change occurred.
public string DatabaseName { get; init; }
Property Value
DocumentKey
Gets the document key that identifies the affected document.
public BsonDocument? DocumentKey { get; init; }
Property Value
- BsonDocument
Remarks
This typically contains the _id field of the document.
FullDocument
Gets the full document after the change (for insert, update with full document, or replace).
public BsonDocument? FullDocument { get; init; }
Property Value
- BsonDocument
Remarks
Available when FullDocument option is enabled in the change stream.
FullDocumentBeforeChange
Gets the document as it was before the change (MongoDB 6.0+).
public BsonDocument? FullDocumentBeforeChange { get; init; }
Property Value
- BsonDocument
Remarks
Available when FullDocumentBeforeChange option is enabled and the collection has change stream pre and post images enabled.
FullNamespace
Gets the fully qualified namespace (database.collection).
public string FullNamespace { get; }
Property Value
Position
Gets the resume token position of this change.
public MongoDbCdcPosition Position { get; init; }
Property Value
UpdateDescription
Gets the update description containing modified fields and removed fields.
public MongoDbUpdateDescription? UpdateDescription { get; init; }
Property Value
Remarks
Only present for update operations.
WallTime
Gets the wall clock time when the change was recorded.
public DateTimeOffset? WallTime { get; init; }
Property Value
Methods
CreateDelete(MongoDbCdcPosition, string, string, BsonDocument?, BsonDocument?, BsonTimestamp?, DateTimeOffset?)
Creates a new instance for a delete operation.
public static MongoDbDataChangeEvent CreateDelete(MongoDbCdcPosition position, string databaseName, string collectionName, BsonDocument? documentKey, BsonDocument? fullDocumentBeforeChange, BsonTimestamp? clusterTime, DateTimeOffset? wallTime)
Parameters
positionMongoDbCdcPositiondatabaseNamestringcollectionNamestringdocumentKeyBsonDocumentfullDocumentBeforeChangeBsonDocumentclusterTimeBsonTimestampwallTimeDateTimeOffset?
Returns
CreateDrop(MongoDbCdcPosition, string, string, BsonTimestamp?, DateTimeOffset?)
Creates a new instance for a drop operation.
public static MongoDbDataChangeEvent CreateDrop(MongoDbCdcPosition position, string databaseName, string collectionName, BsonTimestamp? clusterTime, DateTimeOffset? wallTime)
Parameters
positionMongoDbCdcPositiondatabaseNamestringcollectionNamestringclusterTimeBsonTimestampwallTimeDateTimeOffset?
Returns
CreateInsert(MongoDbCdcPosition, string, string, BsonDocument?, BsonDocument?, BsonTimestamp?, DateTimeOffset?)
Creates a new instance for an insert operation.
public static MongoDbDataChangeEvent CreateInsert(MongoDbCdcPosition position, string databaseName, string collectionName, BsonDocument? documentKey, BsonDocument? fullDocument, BsonTimestamp? clusterTime, DateTimeOffset? wallTime)
Parameters
positionMongoDbCdcPositiondatabaseNamestringcollectionNamestringdocumentKeyBsonDocumentfullDocumentBsonDocumentclusterTimeBsonTimestampwallTimeDateTimeOffset?
Returns
CreateInvalidate(MongoDbCdcPosition, BsonTimestamp?, DateTimeOffset?)
Creates a new instance for an invalidate operation.
public static MongoDbDataChangeEvent CreateInvalidate(MongoDbCdcPosition position, BsonTimestamp? clusterTime, DateTimeOffset? wallTime)
Parameters
positionMongoDbCdcPositionclusterTimeBsonTimestampwallTimeDateTimeOffset?
Returns
CreateReplace(MongoDbCdcPosition, string, string, BsonDocument?, BsonDocument?, BsonDocument?, BsonTimestamp?, DateTimeOffset?)
Creates a new instance for a replace operation.
public static MongoDbDataChangeEvent CreateReplace(MongoDbCdcPosition position, string databaseName, string collectionName, BsonDocument? documentKey, BsonDocument? fullDocument, BsonDocument? fullDocumentBeforeChange, BsonTimestamp? clusterTime, DateTimeOffset? wallTime)
Parameters
positionMongoDbCdcPositiondatabaseNamestringcollectionNamestringdocumentKeyBsonDocumentfullDocumentBsonDocumentfullDocumentBeforeChangeBsonDocumentclusterTimeBsonTimestampwallTimeDateTimeOffset?
Returns
CreateUpdate(MongoDbCdcPosition, string, string, BsonDocument?, BsonDocument?, BsonDocument?, MongoDbUpdateDescription?, BsonTimestamp?, DateTimeOffset?)
Creates a new instance for an update operation.
public static MongoDbDataChangeEvent CreateUpdate(MongoDbCdcPosition position, string databaseName, string collectionName, BsonDocument? documentKey, BsonDocument? fullDocument, BsonDocument? fullDocumentBeforeChange, MongoDbUpdateDescription? updateDescription, BsonTimestamp? clusterTime, DateTimeOffset? wallTime)
Parameters
positionMongoDbCdcPositiondatabaseNamestringcollectionNamestringdocumentKeyBsonDocumentfullDocumentBsonDocumentfullDocumentBeforeChangeBsonDocumentupdateDescriptionMongoDbUpdateDescriptionclusterTimeBsonTimestampwallTimeDateTimeOffset?