Trigger Data Format
Overall Data Format
Trigger data follows the cloudevent specification.
Variable | Description |
---|---|
$requestId | Unique request identifier |
$docId | Document ID for the cloud database change |
$region | Region information |
$envId | Environment ID |
$table | Cloud database collection name |
$action | Cloud database action, 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": { // The document after modification
"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'] // Removed fields; null if none
}
}
Cloud Database
Variable | Type | Description |
---|---|---|
docId | string | Record id to be updated |
doc | object | Updated document for update operations, inserted document for insert operations, document before deletion for delete operations |
dataType | string | Type of data update, indicating the specific operation performed on the record. Enum values: update, delete, insert |
updatedFields | object | All updated fields and their new values after the update, with keys representing the field paths and values representing the post-update field values. Present only for update operations. |
RemovedFields | string[] | All removed fields; present only for update operations |