Skip to main content

data

Trigger Data Format

Overall Data Format

Trigger data adheres to the cloudevents specification.

VariableDescription
$requestIdrequestId that uniquely identifies the request
$docIddocument ID for database changes
$regionRegion
$envIdEnvironment ID
$tableDatabase collection name
$actionDatabase actions, 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": { // 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

VariableTypeDescription
docIdstringUpdated record id
docobjectFor update: the updated document; for insert: the inserted document; for delete: the document before deletion
dataTypestringData update type, indicating the specific update type of the record. Enum values: update, delete, insert
updatedFieldsobjectAll 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.
RemovedFieldsstring[]All removed fields. Only present during update operations.