{_id : { <BSON Object> },"operationType" : "<operation>","fullDocument" : { <document> },"ns" : {"db" : "<database>","coll" : "<collection>"},"to" : {"db" : "<database>","coll" : "<collection>"},"documentKey" : { "_id" : <value> },"updateDescription" : {"updatedFields" : { <document> },"removedFields" : [ "<field>", ... ],"truncatedArrays" : [{ "field" : <field>, "newSize" : <integer> },...]},"clusterTime" : <Timestamp>,"txnNumber" : <NumberLong>,"lsid" : {"id" : <UUID>,"uid" : <BinData>}}
Field | Type | Description |
_id | document | A BSON object used to uniquely identify the event. The format of the _id object is as follows: { "_data" : <BinData|hex string>}. The type of _data depends on the version of MongoDB. For a complete description of the _data type, see Resume Tokens. |
operationType | string | This field indicates the operation types that trigger the change events, including the following 8 types: insert, delete, replace, update, drop, rename, dropDatabase, and invalidate. |
fullDocument | document | This field indicates the documents affected by the insert, replace, delete, and update operations. For insert and replace operations, this field indicates the new document. For delete operations, this field is omitted, indicating the document no longer exists. For update operations, this field is shown only if fullDocument is configured as updateLookup. |
ns | document | Refers to the namespace, consisting of the database and collection. |
ns.db | string | Refers to the database name. |
ns.coll | string | Refers to the collection name. For dropDatabase operations, this field is omitted. |
to | document | When the operation type is Rename, this field indicates the new collection name. This field is omitted for other operations. |
to.db | string | Refers to the name of the new database. |
to.coll | string | Refers to the new collection name. |
documentKey | document | Refers to the ID of the document modified by the operation. |
updateDescription | document | Refers to a document that describes the field modified by the update operation. This field is present only if the event corresponds to an update operation. |
updateDescription.updatedFields | document | This field contains the fields modified by the update operation, with the value of the field being the updated value. |
updateDescription.removedFields | array | This field contains the fields deleted by the update operation. |
updateDescription.truncatedArrays | array | This field records the array truncation performed using one or more of the following pipeline-based updates:$addFields$set$replaceRoot$replaceWith |
updateDescription.truncatedArrays.field | string | Indicates the field that was removed. |
updateDescription.truncatedArrays.newSize | integer | Refers to the number of elements in the truncated array. |
clusterTime | Timestamp | Refers to the oplog timestamp associated with the event. For events involving Multi-Document Transactions, the clusterTime values associated with the event are the same. |
txnNumber | NumberLong | |
lsid | Document | Refers to the session ID associated with the transaction. It appears only when the operation is a Multi-Document Transaction. |
{_id: { < Resume Token > },operationType: 'insert',clusterTime: <Timestamp>,ns: {db: 'engineering',coll: 'users'},documentKey: {userName: 'alice123',_id: ObjectId("599af247bb69cd8996xxxxxx")},fullDocument: {_id: ObjectId("599af247bb69cd8996xxxxxx"),userName: 'alice123',name: 'Alice'}}
{_id: { < Resume Token > },operationType: 'update',clusterTime: <Timestamp>,ns: {db: 'engineering',coll: 'users'},documentKey: {_id: ObjectId("58a4eb4a30c75625e0xxxxxx")},updateDescription: {updatedFields: {email: 'alice@10gen.com'},removedFields: ['phoneNumber'],truncatedArrays: [ {"field" : "vacation_time","newSize" : 36} ]}}
update
event with the fullDocument : updateLookup
option configured:{_id: { < Resume Token > },operationType: 'update',clusterTime: <Timestamp>,ns: {db: 'engineering',coll: 'users'},documentKey: {_id: ObjectId("58a4eb4a30c75625e0xxxxxx")},updateDescription: {updatedFields: {email: 'alice@10gen.com'},removedFields: ['phoneNumber'],truncatedArrays: [ {"field" : "vacation_time","newSize" : 36} ]},fullDocument: {_id: ObjectId("58a4eb4a30c75625e0xxxxxx"),name: 'Alice',userName: 'alice123',email: 'alice@10gen.com',team: 'replication'}}
{_id: { < Resume Token > },operationType: 'replace',clusterTime: <Timestamp>,ns: {db: 'engineering',coll: 'users'},documentKey: {_id: ObjectId("599af247bb69cd8996xxxxxx")},fullDocument: {_id: ObjectId("599af247bb69cd8996xxxxxx"),userName: 'alice123',name: 'Alice'}}
replace
operation is performed in two steps:documentKey
.documentkey
.replace
event, the fullDocument
field represents the new document inserted.{_id: { < Resume Token > },operationType: 'delete',clusterTime: <Timestamp>,ns: {db: 'engineering',coll: 'users'},documentKey: {_id: ObjectId("599af247bb69cd8996xxxxxx")}}
fullDocument
field is omitted.{_id: { < Resume Token > },operationType: 'drop',clusterTime: <Timestamp>,ns: {db: 'engineering',coll: 'users'}}
{_id: { < Resume Token > },operationType: 'rename',clusterTime: <Timestamp>,ns: {db: 'engineering',coll: 'users'},to: {db: 'engineering',coll: 'people'}}
{_id: { < Resume Token > },operationType: 'dropDatabase',clusterTime: <Timestamp>,ns: {db: 'engineering'}}
{_id: { < Resume Token > },operationType: 'invalidate',clusterTime: <Timestamp>}
Was this page helpful?