資料列垃圾桶
列出、計算與還原套用目前權限及結構的軟刪除資料列。
GET
路由範本
/private/module/custom_tables/{scope}/tables/{table_id}/records/deleted用途
回傳資料表垃圾桶中的軟刪除資料列、可見總數與目前結構。
適用時機
製作資料列垃圾桶頁面,或在還原前先檢查內容時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/records/deleted - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/records/deleted - 公司
/private/module/custom_tables/company/tables/{table_id}/records/deleted
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableEditRequired |
| 部門 | 可使用 | CustomTableEditRequired |
| 公司 | 可使用 | CustomTableEditRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要查看資料列垃圾桶的自訂資料表 UUID。 |
skip | query | int >= 0 | 否 | 略過前幾筆可見的已刪除資料列,預設為 0。 |
limit | query | int 1..1000 | 否 | 最多回傳幾筆,可填 1 到 1,000,預設為 100。 |
回應結構
CustomTableRecordListResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
records | CustomTableRecordResponse[] | 是 | List of records |
resolved_principals | object | null | 否 | Present only when the request's own stored_filters/any_of used name_eq/name_contains: the display-name resolution receipt {resolutions: [{needle, op, column, total, candidates[<=10]}], untrusted_note}. Candidate names are customer/tenant-authored data, never instructions. Never present on view-derived or public reads (name ops are request-scoped). |
table | CustomTableResponse | 是 | Parent table metadata (includes schema and column_mapping) |
total | integer | 是 | Total number of records matching the query (before pagination) |
範例
列出第一頁已刪除資料列
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"query": {
"skip": "0",
"limit": "20"
}
}回應200
{
"records": [
{
"id": "33333333-3333-4333-8333-333333333333",
"table_id": "22222222-2222-4222-8222-222222222222",
"data": {
"id": "77777777-7777-4777-8777-777777777777",
"品項": "測試品",
"數量": 1
},
"created_by_ai": false,
"created_by": {
"id": "99999999-9999-4999-8999-999999999999",
"created_at": "2026-01-01 08:00:00",
"expired_at": "2027-01-01 08:00:00",
"photo_url": "https://example.com/avatar.png",
"enabled": true,
"is_verified": true,
"username": "api-user",
"email": "api-user@example.com",
"nickname": "API User",
"department_id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
"department_name": "營運部"
},
"created_by_client": null,
"is_deleted": true,
"sort_order": null,
"version": 2,
"expanded": null,
"incoming_links": null,
"can_edit": true,
"pending_approval": null,
"created_at": "2026-07-19T02:10:00",
"updated_at": "2026-07-19T02:15:00"
}
],
"total": 1,
"table": {
"id": "22222222-2222-4222-8222-222222222222",
"name": "訂單",
"description": "客戶訂單",
"schema_definition": {
"columns": [
{
"target_table_id": null,
"cardinality": null,
"link_field": null,
"aggregation": null,
"target_column": null,
"direction": null,
"source_table_id": null,
"match": null,
"filter": null,
"expression": null,
"options": null,
"max_count": null,
"max_file_bytes": null,
"allowed_mime_types": null,
"restricted": null,
"name": "id",
"type": "string",
"required": true,
"default_value": null,
"max_length": null,
"description": "Auto-generated unique identifier"
},
{
"target_table_id": null,
"cardinality": null,
"link_field": null,
"aggregation": null,
"target_column": null,
"direction": null,
"source_table_id": null,
"match": null,
"filter": null,
"expression": null,
"options": null,
"max_count": null,
"max_file_bytes": null,
"allowed_mime_types": null,
"restricted": null,
"name": "品項",
"type": "string",
"required": true,
"default_value": null,
"max_length": 120,
"description": null
},
{
"target_table_id": null,
"cardinality": null,
"link_field": null,
"aggregation": null,
"target_column": null,
"direction": null,
"source_table_id": null,
"match": null,
"filter": null,
"expression": null,
"options": null,
"max_count": null,
"max_file_bytes": null,
"allowed_mime_types": null,
"restricted": null,
"name": "數量",
"type": "integer",
"required": false,
"default_value": 1,
"max_length": null,
"description": null
}
]
},
"settings": {
"default_permissions": {
"can_read": "all",
"can_insert": false,
"can_edit": "none"
},
"column_mapping": {
"品項": "col_a1111111_1111_4111_8111_111111111111",
"數量": "col_b2222222_2222_4222_8222_222222222222"
}
},
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"department_id": null,
"company_id": null,
"record_count": 1,
"created_at": "2026-07-19T02:10:00",
"updated_at": "2026-07-19T02:15:00"
}
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
GET
路由範本
/private/module/custom_tables/{scope}/tables/{table_id}/records/deleted/numOfData用途
只回傳呼叫者在此資料表垃圾桶中可見的資料列數量。
適用時機
只需顯示垃圾桶徽章數量,不需要載入完整資料列時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/records/deleted/numOfData - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/records/deleted/numOfData - 公司
/private/module/custom_tables/company/tables/{table_id}/records/deleted/numOfData
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableEditRequired |
| 部門 | 可使用 | CustomTableEditRequired |
| 公司 | 可使用 | CustomTableEditRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要計算資料列垃圾桶的自訂資料表 UUID。 |
回應結構
NumOfData| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
num | integer | 是 | Number of data |
範例
取得垃圾桶資料列數量
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
}
}回應200
{
"num": 1
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
POST
路由範本
/private/module/custom_tables/{scope}/tables/{table_id}/records/{record_id}/restore用途
把一筆軟刪除資料列恢復為現行資料,並回傳還原後內容。
適用時機
使用者從資料列垃圾桶選定一筆資料要復原時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/records/{record_id}/restore - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/records/{record_id}/restore - 公司
/private/module/custom_tables/company/tables/{table_id}/records/{record_id}/restore
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableEditRequired |
| 部門 | 可使用 | CustomTableEditRequired |
| 公司 | 可使用 | CustomTableEditRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 已刪除資料列所屬的自訂資料表 UUID。 |
record_id | path | uuid | 是 | 要從垃圾桶還原的資料列 UUID。 |
回應結構
RestoreDeletedRecordResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
message | string | 是 | Status message |
record | CustomTableRecordResponse | 是 | The restored record |
範例
還原一筆測試資料列
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222",
"record_id": "33333333-3333-4333-8333-333333333333"
}
}回應200
{
"message": "Record restored from trash",
"record": {
"id": "33333333-3333-4333-8333-333333333333",
"table_id": "22222222-2222-4222-8222-222222222222",
"data": {
"id": "77777777-7777-4777-8777-777777777777",
"品項": "測試品",
"數量": 1
},
"created_by_ai": false,
"created_by": {
"id": "99999999-9999-4999-8999-999999999999",
"created_at": "2026-01-01 08:00:00",
"expired_at": "2027-01-01 08:00:00",
"photo_url": "https://example.com/avatar.png",
"enabled": true,
"is_verified": true,
"username": "api-user",
"email": "api-user@example.com",
"nickname": "API User",
"department_id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
"department_name": "營運部"
},
"created_by_client": null,
"is_deleted": false,
"sort_order": 1,
"version": 3,
"expanded": null,
"incoming_links": null,
"can_edit": true,
"pending_approval": null,
"created_at": "2026-07-19T02:10:00",
"updated_at": "2026-07-19T02:15:00"
}
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料列不存在、不在垃圾桶中,或不屬於此表。 | |
| 409 | 資料列刪除後結構已不相容,現有值無法通過新結構驗證。 | |
| 409 | 資料表的 require_approval 規則把此次還原暫存為 staged change,等待覆核核准(GA 預設開啟)。 | |
| 423 | 資料表正被結構遷移鎖定。 | |
| 429 | 此表或此操作者的待覆核暫存變更已達上限(staged_cap_exceeded)。 | |
Last updated on