data
Trigger Data Format
Overall Data Format
Trigger data adheres to the cloudevents specification.
| Variable | Description |
|---|---|
| $requestId | requestId that uniquely identifies the request |
| $docId | document ID for database changes |
| $region | Region |
| $envId | Environment ID |
| $table | Database collection name |
| $action | Database actions, including insert/delete/update |
| $ruleId | Trigger ID |
// Data format
{
"specversion": "1.0",
"id": "{$requestId}.{$docId}",
"source": "tcb/database.{$region}.{$envId}.{$table}",
"type": "com.tcb.database.{$action}",
"subject": "{$ruleId}.{$docId}", //
"datacontenttype": "application/json",
"time": "2021-08-20T07:50:24.443501693Z",
"data": { // data is the specific information passed from the trigger event source
}
}
// Example
{
"specversion": "1.0",
"id": "8bf9b12d-2869-445f-8f9d-5d22908db3ba.14139e126142e1cc0cddb10d725c8116",
"source": "tcb/database.ap-shanghai.env-abcdefg.blog",
"type": "com.tcb.database.insert",
"subject": "test-trigger.14139e126142e1cc0cddb10d725c8116",
"datacontenttype": "application/json",
"time": "2021-08-20T07:50:24.443501693Z",
"data": {
"docId": "e17e694a614bdaa700002b653e63e880",
"doc": { // Updated document
"Name": "6a9f9a16-e355-4b9e-9ed6-b19b2ab41443",
"_id": "e17e694a614bdaa700002b653e63e880"
},
"dataType": "insert", // Change type, enum: insert/update/delete
"updatedFields": {"Student.Name.Second":"abcdfd"}, // Updated field information, null if not updated
"RemovedFields": ['demo'] // Which fields were removed, null if none were removed
}
}
Database
| Variable | Type | Description |
|---|---|---|
| docId | string | Updated record id |
| doc | object | For update: the updated document; for insert: the inserted document; for delete: the document before deletion |
| dataType | string | Data update type, indicating the specific update type of the record. Enum values: update, delete, insert |
| updatedFields | object | All updated fields and their values after update. The key is the updated field path, and the value is the updated field value. Only present during update operations. |
| RemovedFields | string[] | All removed fields. Only present during update operations. |