Skip to main content

Trigger Data Format

Overall Data Format

Trigger data follows the cloudevent specification.

VariableDescription
$requestIdUnique request identifier
$docIdDocument ID for the cloud database change
$regionRegion information
$envIdEnvironment ID
$tableCloud database collection name
$actionCloud database action, including insert/delete/update
$ruleIdTrigger 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

VariableTypeDescription
docIdstringRecord id to be updated
docobjectUpdated document for update operations, inserted document for insert operations, document before deletion for delete operations
dataTypestringType of data update, indicating the specific operation performed on the record. Enum values: update, delete, insert
updatedFieldsobjectAll 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.
RemovedFieldsstring[]All removed fields; present only for update operations