This chapter details the data model based process and Gou Query DSL has two data query methods. It is recommended to learn the basics of relational databases and understand SQL syntax before reading , you can write basic SQL statements.
Data model processes Find
, Get
, Paginate
, UpdateWhere
, DeleteWhere
, DestroyWhere
all support the incoming query parameter Object QueryParam
to limit the scope of reading records.
Object QueryParam:
Data structure description:
Query DSL can be used in data streams, and is generally used for more complex scenarios such as data analysis and statistics.
Analyze the data table service
(see the table below) and count the highest scores in each industry.
id | industries | city | score | created_at | updated_at |
---|---|---|---|---|---|
1 | ["Tourism", "Education"] | Beijing | 99 | 2021-10-03 13:40:52 | NULL |
2 | ["Tourism", "Education"] | Shanghai | 68 | 2021-10-03 13:40:52 | NULL |
3 | ["Tourism", "Education"] | Beijing | 92 | 2021-10-03 13:40:52 | NULL |
4 | ["Tourism", "Education"] | Shanghai | 87 | 2021-10-03 13:40:52 | NULL |
5 | ["Tourism", "Education"] | Beijing | 71 | 2021-10-03 13:46:06 | NULL |
Query DSL example:
In a data flow, you can use {{$in}}
or ?:$in
to receive parameters, and {{$res}}
or ?:$res
to refer to node query results.
{"label": "Query latest data","version": "1.0.0","description": "Query the latest data of the system","nodes": [{"name": "pet","process": "models.pet.Get","args": [{"select": ["id", "name", "kind", "created_at"],"wheres": [{ "column": "kind", "value": "{{$in.0}}" }],"orders": [{ "column": "created_at", "option": "desc" }],"limit": 10}]}],"output": "{{$res.pet}}"}
{"label": "Query latest data","version": "1.0.0","description": "Query the latest data of the system","nodes": [{"name": "pet","engine": "xiang","query": {"select": ["id", "name", "kind", "created_at"],"from": "$pet","wheres": [{ ":kind": "type", "=": "?:$in.0" }],"orders": "created_at desc","limit": 10}}],"output": "{{$res.pet}}"}
function test(id) {var query = new Query();var data = query.Get({name: "pet",engine: "xiang",query: {select: ["id", "name", "kind", "created_at"],from: "$pet",wheres: [{ ":kind": "type", "=": id }],orders: "created_at desc",limit: 10,},});}
In data tables, query parameters can be passed using filter
. Query parameters are passed to the data table interface via URL Query String
.
Specify the query parameter name:
{"name": "pet","version": "1.0.0","decription": "Pet Management Form","bind": { "model": "pet" },"apis": {},"columns": {},"filters": {"Key words": {"label": "Keyword","bind": "where.name.match","input": { "type": "input", "props": { "placeholder": "Please enter keywords" } }}},"list": {"filters": ["Keywords"],...},"edit": {}}
When clicking the search button on the interface, the system requests data from the form search
API, and passes in the parameter name declared in bind
and the value filled in by the user:
GET /api/xiang/table/pet?where.name.match=xxx
This chapter details the data model based process and Gou Query DSL has two data query methods. It is recommended to learn the basics of relational databases and understand SQL syntax before reading , you can write basic SQL statements.
Data model processes Find
, Get
, Paginate
, UpdateWhere
, DeleteWhere
, DestroyWhere
all support the incoming query parameter Object QueryParam
to limit the scope of reading records.
Object QueryParam:
Data structure description:
Query DSL can be used in data streams, and is generally used for more complex scenarios such as data analysis and statistics.
Analyze the data table service
(see the table below) and count the highest scores in each industry.
id | industries | city | score | created_at | updated_at |
---|---|---|---|---|---|
1 | ["Tourism", "Education"] | Beijing | 99 | 2021-10-03 13:40:52 | NULL |
2 | ["Tourism", "Education"] | Shanghai | 68 | 2021-10-03 13:40:52 | NULL |
3 | ["Tourism", "Education"] | Beijing | 92 | 2021-10-03 13:40:52 | NULL |
4 | ["Tourism", "Education"] | Shanghai | 87 | 2021-10-03 13:40:52 | NULL |
5 | ["Tourism", "Education"] | Beijing | 71 | 2021-10-03 13:46:06 | NULL |
Query DSL example:
In a data flow, you can use {{$in}}
or ?:$in
to receive parameters, and {{$res}}
or ?:$res
to refer to node query results.
{"label": "Query latest data","version": "1.0.0","description": "Query the latest data of the system","nodes": [{"name": "pet","process": "models.pet.Get","args": [{"select": ["id", "name", "kind", "created_at"],"wheres": [{ "column": "kind", "value": "{{$in.0}}" }],"orders": [{ "column": "created_at", "option": "desc" }],"limit": 10}]}],"output": "{{$res.pet}}"}
{"label": "Query latest data","version": "1.0.0","description": "Query the latest data of the system","nodes": [{"name": "pet","engine": "xiang","query": {"select": ["id", "name", "kind", "created_at"],"from": "$pet","wheres": [{ ":kind": "type", "=": "?:$in.0" }],"orders": "created_at desc","limit": 10}}],"output": "{{$res.pet}}"}
function test(id) {var query = new Query();var data = query.Get({name: "pet",engine: "xiang",query: {select: ["id", "name", "kind", "created_at"],from: "$pet",wheres: [{ ":kind": "type", "=": id }],orders: "created_at desc",limit: 10,},});}
In data tables, query parameters can be passed using filter
. Query parameters are passed to the data table interface via URL Query String
.
Specify the query parameter name:
{"name": "pet","version": "1.0.0","decription": "Pet Management Form","bind": { "model": "pet" },"apis": {},"columns": {},"filters": {"Key words": {"label": "Keyword","bind": "where.name.match","input": { "type": "input", "props": { "placeholder": "Please enter keywords" } }}},"list": {"filters": ["Keywords"],...},"edit": {}}
When clicking the search button on the interface, the system requests data from the form search
API, and passes in the parameter name declared in bind
and the value filled in by the user:
GET /api/xiang/table/pet?where.name.match=xxx