create Event
On this page
Summary
create
New in version 6.0.
A
create
event occurs when a collection is created on a watched database and the change stream has the showExpandedEvents option set totrue
.
Description
Field | Type | Description | |||
---|---|---|---|---|---|
_id | 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 | |||
clusterTime | 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 Events with the same To identify events for a single transaction, you can use the
combination of Changed in version 8.0. | |||
collectionUUID | UUID | If the change occurred on a collection, New in version 6.0. | |||
lsid | document | The identifier for the session associated with the transaction. Only present if the operation is part of a multi-document transaction. | |||
ns | document | The namespace (database and or collection) affected by the event. | |||
ns.coll | string | The name of the collection where the event occurred. | |||
ns.db | string | The name of the database where the event occurred. | |||
operationDescription | document | Additional information on the change operation. This document and its subfields only appears when the change stream uses expanded events. New in version 6.0. | |||
operationDescription. idIndex | document | The default New in version 6.0. | |||
operationType | string | The type of operation that the change notification reports. Returns a value of | |||
txnNumber | 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. | |||
wallTime | The server date and time of the database operation. New in version 6.0. |
Example
The following example shows a create
event:
{ "_id": { <ResumeToken> }, "operationType": "create", "clusterTime": Timestamp({ t: 1654894547, i: 24 }), "collectionUUID": UUID("98046a1a-b649-4e5b-9c75-67594221ce19"), "wallTime": ISODate("2022-06-10T20:55:47.947Z"), "ns": { "db": "test", "coll": "names" }, "operationDescription": { "idIndex": { "v": 2, "key": { _id: 1 }, "name": "_id_" } } }