yao-app-ts-types
Version:
typescript types for yao application
304 lines • 9.44 kB
JSON
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/YaoQuery.QueryDSL",
"definitions": {
"YaoQuery.QueryDSL": {
"type": "object",
"properties": {
"comment": {
"type": "string",
"description": "备注"
},
"select": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.Expression"
},
"description": "选择字段列表"
},
"from": {
"type": "string",
"description": "查询数据表名称或数据模型"
},
"wheres": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.Where"
},
"description": "数据查询条件"
},
"orders": {
"$ref": "#/definitions/YaoQuery.Orders",
"description": "排序条件"
},
"offset": {
"type": "number",
"description": "记录开始位置"
},
"first": {
"anyOf": [
{
"type": "boolean"
},
{}
],
"description": "只读取第一条"
},
"limit": {
"type": "number",
"description": "读取数据的数量"
},
"page": {
"type": "number",
"description": "分页查询当前页面页码"
},
"pagesize": {
"type": "number",
"description": "每页读取记录数量"
},
"data-only": {
"type": "boolean",
"description": "设定为 true, 查询结果为 []Record; 设定为 false, 查询结果为 Paginate, 仅在设定 `page` 或 `pagesize`时有效。"
},
"groups": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#/definitions/YaoQuery.Group"
},
{
"type": "string"
}
]
},
"description": "聚合字段和统计层级设置"
},
"havings": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.Having"
},
"description": "聚合查询结果筛选, 仅在设定 `groups` 时有效"
},
"unions": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.QueryDSL"
},
"description": "联合查询。多个查询将结果合并为一张表"
},
"query": {
"$ref": "#/definitions/YaoQuery.QueryDSL",
"description": "子查询。按 QueryDSL 描述查询逻辑,生成一张二维数据表或数值。"
},
"name": {
"type": "string",
"description": "子查询别名"
},
"joins": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.Join"
},
"description": "表连接。连接数据量较大的数据表时 **不推荐使用**。| 否 |"
},
"sql": {
"$ref": "#/definitions/YaoQuery.SQL",
"description": "SQL 语句。**非必要,勿使用**"
},
"debug": {
"type": "boolean",
"description": "是否开启调试(开启后计入查询日志)"
}
},
"additionalProperties": false,
"description": "QueryDSL Gou Query Domain Specific Language"
},
"YaoQuery.Expression": {
"type": "string"
},
"YaoQuery.Where": {
"type": "object",
"properties": {
"field": {
"type": "string",
"description": "查询字段"
},
"value": {
"type": "string",
"description": "匹配数值"
},
"op": {
"type": "string",
"description": "匹配关系运算符 `=`,`like`,`in`,`>=` 等,默认为 `=`\n\n| 匹配关系 | 说明 | | -------- | -------------------------------- | | = | 默认值 等于 WHERE 字段 = 数值 | | like | 匹配 WHERE 字段 like 数值 | | match | 匹配 WHERE 字段 全文检索 | | > | 大于 WHERE 字段 > 数值 | | >= | 大于等于 WHERE 字段 >= 数值 | | < | 小于 WHERE 字段 < 数值 | | <= | 小于等于 WHERE 字段 <= 数值 | | is | 为空 WHERE 字段 null / not null | | in | 列表包含 WHERE 字段 IN (数值...) | | <> | 不等于匹配值 |"
},
"or": {
"type": "boolean",
"description": "true 查询条件逻辑关系为 or, 默认为 false 查询条件逻辑关系为 and"
},
"query": {
"$ref": "#/definitions/YaoQuery.QueryDSL",
"description": "子查询, 如设定 query 则忽略 value 数值。"
},
"comment": {
"type": "string",
"description": "查询条件注释"
},
"=": {
"description": "Supported operators with their respective value types"
},
">": {},
">=": {},
"<": {},
"<=": {},
"<>": {},
"like": {},
"match": {},
"in": {},
"is": {
"type": "null",
"description": "check is field is null or not\n\nexample:\n\n{ \"field\": \"name\", \"is\": \"null\" },\n\n{ \"field\": \"name\", \"is\": \"not null\" },"
},
"wheres": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.Where"
},
"description": "分组查询。用于 condition 1 and ( condition 2 OR condition 3) 的场景"
}
},
"additionalProperties": {
"description": "可以使用类似简化的操作,比如:{ \":score\": \"分数\", \"in\": [10, 20] }"
},
"description": "Where 查询条件"
},
"YaoQuery.Orders": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.Order"
},
"description": "Orders 排序条件集合"
},
"YaoQuery.Order": {
"type": "object",
"properties": {
"field": {
"type": "string",
"description": "排序字段"
},
"sort": {
"type": "string",
"description": "排序方式"
},
"comment": {
"type": "string",
"description": "查询条件注释"
}
},
"required": [
"field"
],
"additionalProperties": false,
"description": "Order 排序条件"
},
"YaoQuery.Group": {
"type": "object",
"properties": {
"field": {
"$ref": "#/definitions/YaoQuery.Expression",
"description": "排序字段"
},
"rollup": {
"type": "string",
"description": "同时返回多层级统计结果,对应聚合字段数值的名称。"
},
"comment": {
"type": "string",
"description": "查询条件注释"
}
},
"additionalProperties": false,
"description": "Group 聚合条件"
},
"YaoQuery.Having": {
"type": "object",
"properties": {
"havings": {
"type": "array",
"items": {
"$ref": "#/definitions/YaoQuery.Having"
},
"description": "分组查询。用于 condition 1 and ( condition 2 OR condition 3) 的场景"
}
},
"additionalProperties": false,
"description": "Having 聚合结果筛选条件"
},
"YaoQuery.Join": {
"type": "object",
"properties": {
"from": {
"type": "string",
"description": "查询数据表名称或数据模型"
},
"key": {
"anyOf": [
{
"$ref": "#/definitions/YaoQuery.Expression"
},
{
"type": "string"
}
],
"description": "关联连接表字段名称"
},
"foreign": {
"anyOf": [
{
"$ref": "#/definitions/YaoQuery.Expression"
},
{
"type": "string"
}
],
"description": "关联目标表字段名称(需指定表名或别名)"
},
"left": {
"type": "boolean",
"description": "true 连接方式为 LEFT JOIN, 默认为 false 连接方式为 JOIN"
},
"right": {
"type": "boolean",
"description": "true 连接方式为 RIGHT JOIN, 默认为 false 连接方式为 JOIN"
},
"comment": {
"type": "string",
"description": "关联条件注释"
}
},
"additionalProperties": false,
"description": "Join 数据表连接"
},
"YaoQuery.SQL": {
"type": "object",
"properties": {
"stmt": {
"type": "string",
"description": "SQL 语句,不可跟其它sql查询条件一起混用"
},
"args": {
"type": "array",
"items": {},
"description": "绑定参数表"
},
"comment": {
"type": "string",
"description": "SQL语句注释"
}
},
"additionalProperties": false,
"description": "SQL 语句"
}
}
}