update
Event
On this page
Summary
Description
Field | Type | Description | |||
---|---|---|---|---|---|
| Document | A BSON object which serves as an identifier for the
change stream event. This value is used as the
The For an example of resuming a change stream by | |||
| Timestamp |
Due to oplog size limits,
multi-document transactions may create multiple
oplog entries. In a transaction, change stream events staged in a given oplog
entry share the same On sharded clusters, events with the same To identify events for a single transaction, you can use the
combination of | |||
| document | Document that contains the For sharded collections, this field also displays the full shard key
for the document. The | |||
| document | The document created or modified by a CRUD operation. This field only appears if you configured the change stream with
For more information, see Lookup Full Document for Update Operations. | |||
| document | The identifier for the session associated with the transaction. Only present if the operation is part of a multi-document transaction. | |||
| document | The namespace (database and or collection) affected by the event. | |||
| string | The name of the collection where the event occurred. | |||
| string | The name of the database where the event occurred. | |||
| string | The type of operation that the change notification reports. Returns a value of | |||
| document | A document describing the fields that were updated or removed by the update operation. | |||
updateDescription. removedFields | array | An array of fields that were removed by the update operation. | |||
updateDescription. truncatedArrays | array | An array of documents which record array truncations performed with pipeline-based updates using one or more of the following stages: If the entire array is replaced, the truncations will be reported under updateDescription.updatedFields. | |||
updateDescription. truncatedArrays. field | string | The name of the truncated field. | |||
updateDescription. truncatedArrays. newSize | integer | The number of elements in the truncated array. | |||
updateDescription. updatedFields | document | A document whose keys correspond to the fields that were modified by the update operation. The value of each field corresponds to the new value of those fields, rather than the operation that resulted in the new value. | |||
| NumberLong | Together with the lsid, a number that helps uniquely identify a transction. Only present if the operation is part of a multi-document transaction. |
Example
The following example illustrates an update
event:
{ "_id": { <Resume Token> }, "operationType": "update", "clusterTime": <Timestamp>, "ns": { "db": "engineering", "coll": "users" }, "documentKey": { "_id": ObjectId("58a4eb4a30c75625e00d2820") }, "updateDescription": { "updatedFields": { "email": "alice@10gen.com" }, "removedFields": ["phoneNumber"], "truncatedArrays": [ { "field" : "vacation_time", "newSize" : 36 } ] } }
The following example illustrates an update
event for change streams
opened with the fullDocument : updateLookup
option:
{ "_id": { <Resume Token> }, "operationType": "update", "clusterTime": <Timestamp>, "ns": { "db": "engineering", "coll": "users" }, "documentKey": { "_id": ObjectId("58a4eb4a30c75625e00d2820") }, "updateDescription": { "updatedFields": { "email": "alice@10gen.com" }, "removedFields": ["phoneNumber"], "truncatedArrays": [ { "field" : "vacation_time", "newSize" : 36 } ] }, "fullDocument": { "_id": ObjectId("58a4eb4a30c75625e00d2820"), "name": "Alice", "userName": "alice123", "email": "alice@10gen.com", "team": "replication" } }
The fullDocument
document represents the most current majority-committed
version of the updated document. The fullDocument
document may vary from
the document at the time of the update operation depending on the number of
interleaving majority-committed operations that occur between the update
operation and the document lookup.