本章节详细介绍基于数据模型处理器和Gou Query DSL两种数据查询方式。建议在阅读前学习关系型数据库基础知识,了解SQL语法 ,可以编写基本的SQL语句。
数据模型处理器 Find
, Get
, Paginate
, UpdateWhere
, DeleteWhere
, DestroyWhere
均支持传入查询参数 Object QueryParam
,对读取记录范围进行限定。
Object QueryParam:
数据结构说明:
Query DSL 可以在数据流中使用,一般用于数据分析统计等更为复杂的场景。
对数据表 service
(见下表)分析, 统计各行业最高分。
id | industries | city | score | created_at | updated_at |
---|---|---|---|---|---|
1 | ["旅游", "教育"] | 北京 | 99 | 2021-10-03 13:40:52 | NULL |
2 | ["旅游", "教育"] | 上海 | 68 | 2021-10-03 13:40:52 | NULL |
3 | ["旅游", "教育"] | 北京 | 92 | 2021-10-03 13:40:52 | NULL |
4 | ["旅游", "教育"] | 上海 | 87 | 2021-10-03 13:40:52 | NULL |
5 | ["旅游", "教育"] | 北京 | 71 | 2021-10-03 13:46:06 | NULL |
Query DSL 示例:
在数据流中,可以使用 {{$in}}
或 ?:$in
接收参数, {{$res}}
或 ?:$res
引用节点查询结果。
{"label": "查询最新数据","version": "1.0.0","description": "查询系统最新数据","nodes": [{"name": "宠物","process": "models.pet.Get","args": [{"select": ["id", "name", "created_at"],"wheres": [{ "column": "online", "value": "{{$in.0}}" }],"orders": [{ "column": "created_at", "option": "desc" }],"limit": 10}]}],"output": "{{$res.宠物}}"}
{"label": "查询最新数据","version": "1.0.0","description": "查询系统最新数据","nodes": [{"name": "宠物最新数据","engine": "xiang","query": {"select": ["id", "name", "online", "created_at"],"from": "$pet","wheres": [{ ":kind": "类型", "=": "?:$in.0" }],"orders": "created_at desc","limit": 10}}],"output": "{{$res.宠物最新数据}}"}
function test(online) {var query = new Query();var data = query.Get({select: ["id", "name", "online", "created_at"],wheres: [{ ":deleted_at": "删除", "=": null },{ ":online": "类型", "=": online },],orders: "created_at desc",from: "$pet",});return data;}
在数据表格中,可以使用 filter
传递查询参数。查询参数通过 URL Query String
传递给数据表格接口。
指定查询参数名称:
{"name": "宠物","version": "1.0.0","decription": "宠物管理表格","bind": { "model": "pet" },"apis": {},"columns": {},"filters": {"关键词": {"label": "关键词","bind": "where.name.match","input": { "type": "input", "props": { "placeholder": "请输入关键词" } }}},"list": {"filters": ["关键词"],...},"edit": {}}
在点击界面搜索按钮时,系统向表格 search
API 请求数据,并传入 bind
中声明的参数名和用户填写数值:
GET /api/xiang/table/pet?where.name.match=xxx
本章节详细介绍基于数据模型处理器和Gou Query DSL两种数据查询方式。建议在阅读前学习关系型数据库基础知识,了解SQL语法 ,可以编写基本的SQL语句。
数据模型处理器 Find
, Get
, Paginate
, UpdateWhere
, DeleteWhere
, DestroyWhere
均支持传入查询参数 Object QueryParam
,对读取记录范围进行限定。
Object QueryParam:
数据结构说明:
Query DSL 可以在数据流中使用,一般用于数据分析统计等更为复杂的场景。
对数据表 service
(见下表)分析, 统计各行业最高分。
id | industries | city | score | created_at | updated_at |
---|---|---|---|---|---|
1 | ["旅游", "教育"] | 北京 | 99 | 2021-10-03 13:40:52 | NULL |
2 | ["旅游", "教育"] | 上海 | 68 | 2021-10-03 13:40:52 | NULL |
3 | ["旅游", "教育"] | 北京 | 92 | 2021-10-03 13:40:52 | NULL |
4 | ["旅游", "教育"] | 上海 | 87 | 2021-10-03 13:40:52 | NULL |
5 | ["旅游", "教育"] | 北京 | 71 | 2021-10-03 13:46:06 | NULL |
Query DSL 示例:
在数据流中,可以使用 {{$in}}
或 ?:$in
接收参数, {{$res}}
或 ?:$res
引用节点查询结果。
{"label": "查询最新数据","version": "1.0.0","description": "查询系统最新数据","nodes": [{"name": "宠物","process": "models.pet.Get","args": [{"select": ["id", "name", "created_at"],"wheres": [{ "column": "online", "value": "{{$in.0}}" }],"orders": [{ "column": "created_at", "option": "desc" }],"limit": 10}]}],"output": "{{$res.宠物}}"}
{"label": "查询最新数据","version": "1.0.0","description": "查询系统最新数据","nodes": [{"name": "宠物最新数据","engine": "xiang","query": {"select": ["id", "name", "online", "created_at"],"from": "$pet","wheres": [{ ":kind": "类型", "=": "?:$in.0" }],"orders": "created_at desc","limit": 10}}],"output": "{{$res.宠物最新数据}}"}
function test(online) {var query = new Query();var data = query.Get({select: ["id", "name", "online", "created_at"],wheres: [{ ":deleted_at": "删除", "=": null },{ ":online": "类型", "=": online },],orders: "created_at desc",from: "$pet",});return data;}
在数据表格中,可以使用 filter
传递查询参数。查询参数通过 URL Query String
传递给数据表格接口。
指定查询参数名称:
{"name": "宠物","version": "1.0.0","decription": "宠物管理表格","bind": { "model": "pet" },"apis": {},"columns": {},"filters": {"关键词": {"label": "关键词","bind": "where.name.match","input": { "type": "input", "props": { "placeholder": "请输入关键词" } }}},"list": {"filters": ["关键词"],...},"edit": {}}
在点击界面搜索按钮时,系统向表格 search
API 请求数据,并传入 bind
中声明的参数名和用户填写数值:
GET /api/xiang/table/pet?where.name.match=xxx