Skip to content

对外数据 CRUD + Schema(Token 鉴权) ( data ) 相关文档 ​

列表 ✅ ​

请求地址:GET /data/:table

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)
pagequerynumber否否(无)
sizequerynumber否否(无)
orderquerystring否否(无)
qquerystring否否(无)

使用示例: ​

javascript
// 列表查询 - /data/users 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
input = {};
output = {
  "success": true,
  "data": {
    "rows": [
      {
        "id": 2,
        "name": "bob",
        "age": 25
      }
    ],
    "total": 1,
    "page": 1,
    "size": 20
  }
};

表结构 ✅ ​

请求地址:GET /data/:table/schema

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)

使用示例: ​

javascript
// 表结构 - /data/users/schema 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
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": 1793068068104,
    "updatedAt": 1793068068118
  }
};

单条 ✅ ​

请求地址:GET /data/:table/records/:pk

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)
pkparamsstring否是(无)

使用示例: ​

javascript
// 查询单条 - /data/users/records/2 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
input = {};
output = {
  "success": true,
  "data": {
    "id": 2,
    "name": "bob",
    "age": 25
  }
};

创建 ✅ ​

请求地址:POST /data/:table/records

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)

使用示例: ​

javascript
// 创建记录 - /data/users/records 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
input = {
  "name": "bob",
  "age": 25
};
output = {
  "success": true,
  "data": {
    "id": 2,
    "name": "bob",
    "age": 25
  }
};

更新 ✅ ​

请求地址:PUT /data/:table/records/:pk

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)
pkparamsstring否是(无)

使用示例: ​

javascript
// 更新记录 - /data/users/records/2 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
input = {
  "age": 26
};
output = {
  "success": true,
  "data": {
    "success": true
  }
};

删除 ✅ ​

请求地址:DELETE /data/:table/records/:pk

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)
pkparamsstring否是(无)

使用示例: ​

javascript
// 删除记录 - /data/users/records/2 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
input = {};
output = {
  "success": true,
  "data": {
    "success": true
  }
};

自增 ✅ ​

请求地址:POST /data/:table/incr

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)
pkbodystring否是(无)
fieldbodystring否是(无)
countbodynumber否是(无)

使用示例: ​

javascript
// 自增 - /data/users/incr 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
input = {
  "pk": 2,
  "field": "age",
  "count": 1
};
output = {
  "success": true,
  "data": {
    "success": true
  }
};

新建模型(token) ✅ ​

请求地址:POST /data/_schema/tables

参数: ​

参数名位置类型格式化必填说明
namebodystring否是(无)
labelbodystring否是(无)
fieldsbodyarray否是(无)
notebodystring否否(无)
autoTimestampsbodyboolean否否(无)

使用示例: ​

javascript
// 通过 Token 新建模型 - /data/_schema/tables 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
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": 1793068068210,
    "updatedAt": 1793068068210
  }
};

加字段(token) ✅ ​

请求地址:POST /data/_schema/tables/:table/fields

参数: ​

参数名位置类型格式化必填说明
tableparamsstring否是(无)
fieldbodyrecord否是(无)

使用示例: ​

javascript
// 通过 Token 加字段 - /data/_schema/tables/products/fields 

headers = {
  "Authorization": "Bearer oa_testtoken_ff0orcw9up"
}
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": 1793068068210,
    "updatedAt": 1793068068212
  }
};

基于 MIT 协议发布