对外数据 CRUD + Schema(Token 鉴权) ( data ) 相关文档
列表 ✅
请求地址:GET /data/:table
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
page | query | number | 否 | 否 | (无) |
size | query | number | 否 | 否 | (无) |
order | query | string | 否 | 否 | (无) |
q | query | string | 否 | 否 | (无) |
使用示例:
javascript
// 列表查询 - /data/users
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {};
output = {
"success": true,
"data": {
"rows": [
{
"id": 2,
"name": "bob",
"age": 25
}
],
"total": 1,
"page": 1,
"size": 20
}
};表结构 ✅
请求地址:GET /data/:table/schema
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 表结构 - /data/users/schema
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {};
output = {
"success": true,
"data": {
"id": 1,
"name": "users",
"label": "用户表",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
},
{
"name": "age",
"label": "age",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": "用户信息表",
"createdAt": 1783640695280,
"updatedAt": 1783640695299
}
};单条 ✅
请求地址:GET /data/:table/records/:pk
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
pk | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 查询单条 - /data/users/records/2
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {};
output = {
"success": true,
"data": {
"id": 2,
"name": "bob",
"age": 25
}
};创建 ✅
请求地址:POST /data/:table/records
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 创建记录 - /data/users/records
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {
"name": "bob",
"age": 25
};
output = {
"success": true,
"data": {
"id": 2,
"name": "bob",
"age": 25
}
};更新 ✅
请求地址:PUT /data/:table/records/:pk
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
pk | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 更新记录 - /data/users/records/2
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {
"age": 26
};
output = {
"success": true,
"data": {
"success": true
}
};删除 ✅
请求地址:DELETE /data/:table/records/:pk
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
pk | params | string | 否 | 是 | (无) |
使用示例:
javascript
// 删除记录 - /data/users/records/2
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {};
output = {
"success": true,
"data": {
"success": true
}
};自增 ✅
请求地址:POST /data/:table/incr
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
pk | body | string | 否 | 是 | (无) |
field | body | string | 否 | 是 | (无) |
count | body | number | 否 | 是 | (无) |
使用示例:
javascript
// 自增 - /data/users/incr
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {
"pk": 2,
"field": "age",
"count": 1
};
output = {
"success": true,
"data": {
"success": true
}
};新建模型(token) ✅
请求地址:POST /data/_schema/tables
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
name | body | string | 否 | 是 | (无) |
label | body | string | 否 | 是 | (无) |
fields | body | array | 否 | 是 | (无) |
note | body | string | 否 | 否 | (无) |
autoTimestamps | body | boolean | 否 | 否 | (无) |
使用示例:
javascript
// 通过 Token 新建模型 - /data/_schema/tables
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {
"name": "products",
"label": "商品",
"fields": [
{
"name": "id",
"jsonType": "integer",
"isPrimary": true,
"isAutoIncrement": true
},
{
"name": "name",
"jsonType": "string"
}
]
};
output = {
"success": true,
"data": {
"id": 3,
"name": "products",
"label": "商品",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": null,
"createdAt": 1783640695443,
"updatedAt": 1783640695443
}
};加字段(token) ✅
请求地址:POST /data/_schema/tables/:table/fields
参数:
| 参数名 | 位置 | 类型 | 格式化 | 必填 | 说明 |
|---|---|---|---|---|---|
table | params | string | 否 | 是 | (无) |
field | body | record | 否 | 是 | (无) |
使用示例:
javascript
// 通过 Token 加字段 - /data/_schema/tables/products/fields
headers = {
"Authorization": "Bearer oa_testtoken_bfz7clvk2xp"
}
input = {
"field": {
"name": "price",
"jsonType": "number"
}
};
output = {
"success": true,
"data": {
"id": 3,
"name": "products",
"label": "商品",
"primaryKey": "id",
"fields": [
{
"name": "id",
"label": "id",
"sqliteType": "INTEGER",
"jsonType": "integer",
"nullable": true,
"defaultValue": null,
"isPrimary": true,
"isAutoIncrement": true,
"isHidden": false,
"isReadonly": false
},
{
"name": "name",
"label": "name",
"sqliteType": "TEXT",
"jsonType": "string",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
},
{
"name": "price",
"label": "price",
"sqliteType": "REAL",
"jsonType": "number",
"nullable": true,
"defaultValue": null,
"isPrimary": false,
"isAutoIncrement": false,
"isHidden": false,
"isReadonly": false
}
],
"isPublished": true,
"isEditable": true,
"note": null,
"createdAt": 1783640695443,
"updatedAt": 1783640695447
}
};