按条件查询数据记录, 返回符合条件的结果集
Get
按条件查询, 不分页models.模型名称.Get
参数 | 类型 | 说明 | 示例 |
---|---|---|---|
args[0] | Object QueryParam | 查询条件 | {"wheres":[{"column":"name", "value":"张三"}],"withs":{"manu":{}}} |
Array<Object Row>
数据记录集合
返回符合条件的的数据记录(Key-Value 结构 Object)集合, JSON 类型字段自动解析, AES 字段自动解密。 关联模型作为一个独立字段,字段名称为关联关系名称; hasOne 关联为数据记录 Object , hasMany 关联为数据记录数组 Array\<Object>。
模型 | 模型定义 |
---|---|
user 主 | 模型描述文件 |
manu hasOne | 模型描述文件 |
address hasMany | 模型描述文件 |
models.user.Get
[{"select": ["id", "name", "mobile", "status"],"withs": { "manu": {}, "mother": {}, "addresses": {} },"wheres": [{ "column": "status", "value": "enabled" }],"orders": [{ "column": "id", "option": "desc" }],"limit": 2}]
[{"addresses": [{"city": "威海市","created_at": "2021-09-15T08:34:20+08:00","deleted_at": null,"id": 4,"location": "威海市6号楼6单元6层1056室","province": "山东省","status": "enabled","updated_at": null,"user_id": 3}],"id": 3,"manu": {"contact_mobile": null,"contact_name": null,"created_at": "2021-09-15T08:34:14+08:00","deleted_at": null,"desc": null,"id": 2,"link": null,"logo": null,"name": "象传高新(北京)数字科技有限公司","rank": 9999999,"short_name": "象传高新","status": "enabled","summary": null,"type": "服务商","updated_at": null},"mobile": "13900003333","mother": {"extra": null,"friends": {"friend_id": null,"status": null,"type": null},"id": null,"name": null,"secret": null,"status": null,"type": null},"name": "用户"},{"addresses": [{"city": "海淀区","created_at": "2021-09-15T08:34:20+08:00","deleted_at": null,"id": 3,"location": "华严北里7号楼7单元7层2048室","province": "北京市","status": "enabled","updated_at": null,"user_id": 2}],"id": 2,"manu": {"contact_mobile": null,"contact_name": null,"created_at": "2021-09-15T08:34:14+08:00","deleted_at": null,"desc": null,"id": 1,"link": null,"logo": null,"name": "北京云道天成科技有限公司","rank": 9999999,"short_name": "云道天成","status": "enabled","summary": null,"type": "服务商","updated_at": null},"mobile": "13900002222","mother": {"extra": null,"friends": {"friend_id": null,"status": null,"type": null},"id": null,"name": null,"secret": null,"status": null,"type": null},"name": "员工"}]
Flow
) 中调用:{"nodes": [{"name": "users","process": "models.user.Get","args": [{"select": ["id", "name", "mobile", "status"],"withs": { "manu": {}, "mother": {}, "addresses": {} },"wheres": [{ "column": "status", "value": "enabled" }],"orders": [{ "column": "id", "option": "desc" }],"limit": 2}],"outs": ["{{$out}}"]}]}
API
) 中调用:{"paths": [{"path": "/search","method": "GET","process": "models.user.Get","in": [":params"],"out": {"status": 200,"type": "application/json"}}]}
GET /api/user/search?withs=manu,mother,addresses&where.status.eq=enabled&order=id.desc&select=id,name,mobile,status&limit=2
models/category.mod.yao
文件,写入以下内容:{"name": "书籍分类","table": {"name": "category","comment": "书籍分类"},"columns": [{"label": "ID","name": "id","type": "ID","comment": "ID","primary": true},{"label": "父级id","name": "parent_id","type": "integer","nullable": true},{"label": "分类名称","name": "name","type": "string","length": 128,"index": true}],"relations": {"book": {"type": "hasMany","model": "book","key": "category_id","foreign": "id","query": {}},"parent": {"type": "hasOne","model": "category","key": "id","foreign": "parent_id","query": {}}},"option": {"timestamps": true,"soft_deletes": true},"values": [{"id": 1,"parent_id": null,"name": "文史类"},{"id": 2,"parent_id": 1,"name": "历史"},{"id": 3,"parent_id": 1,"name": "古诗"},{"id": 4,"parent_id": null,"name": "理工类"},{"id": 5,"parent_id": 4,"name": "数学"},{"id": 6,"parent_id": 4,"name": "物理"}]}
function Get() {return Process("models.category.get", {wheres: [{ column: "parent_id", value: null }],});}
执行 yao run scripts.test.Get
按条件查询数据记录, 返回符合条件的结果集
Get
按条件查询, 不分页models.模型名称.Get
参数 | 类型 | 说明 | 示例 |
---|---|---|---|
args[0] | Object QueryParam | 查询条件 | {"wheres":[{"column":"name", "value":"张三"}],"withs":{"manu":{}}} |
Array<Object Row>
数据记录集合
返回符合条件的的数据记录(Key-Value 结构 Object)集合, JSON 类型字段自动解析, AES 字段自动解密。 关联模型作为一个独立字段,字段名称为关联关系名称; hasOne 关联为数据记录 Object , hasMany 关联为数据记录数组 Array\<Object>。
模型 | 模型定义 |
---|---|
user 主 | 模型描述文件 |
manu hasOne | 模型描述文件 |
address hasMany | 模型描述文件 |
models.user.Get
[{"select": ["id", "name", "mobile", "status"],"withs": { "manu": {}, "mother": {}, "addresses": {} },"wheres": [{ "column": "status", "value": "enabled" }],"orders": [{ "column": "id", "option": "desc" }],"limit": 2}]
[{"addresses": [{"city": "威海市","created_at": "2021-09-15T08:34:20+08:00","deleted_at": null,"id": 4,"location": "威海市6号楼6单元6层1056室","province": "山东省","status": "enabled","updated_at": null,"user_id": 3}],"id": 3,"manu": {"contact_mobile": null,"contact_name": null,"created_at": "2021-09-15T08:34:14+08:00","deleted_at": null,"desc": null,"id": 2,"link": null,"logo": null,"name": "象传高新(北京)数字科技有限公司","rank": 9999999,"short_name": "象传高新","status": "enabled","summary": null,"type": "服务商","updated_at": null},"mobile": "13900003333","mother": {"extra": null,"friends": {"friend_id": null,"status": null,"type": null},"id": null,"name": null,"secret": null,"status": null,"type": null},"name": "用户"},{"addresses": [{"city": "海淀区","created_at": "2021-09-15T08:34:20+08:00","deleted_at": null,"id": 3,"location": "华严北里7号楼7单元7层2048室","province": "北京市","status": "enabled","updated_at": null,"user_id": 2}],"id": 2,"manu": {"contact_mobile": null,"contact_name": null,"created_at": "2021-09-15T08:34:14+08:00","deleted_at": null,"desc": null,"id": 1,"link": null,"logo": null,"name": "北京云道天成科技有限公司","rank": 9999999,"short_name": "云道天成","status": "enabled","summary": null,"type": "服务商","updated_at": null},"mobile": "13900002222","mother": {"extra": null,"friends": {"friend_id": null,"status": null,"type": null},"id": null,"name": null,"secret": null,"status": null,"type": null},"name": "员工"}]
Flow
) 中调用:{"nodes": [{"name": "users","process": "models.user.Get","args": [{"select": ["id", "name", "mobile", "status"],"withs": { "manu": {}, "mother": {}, "addresses": {} },"wheres": [{ "column": "status", "value": "enabled" }],"orders": [{ "column": "id", "option": "desc" }],"limit": 2}],"outs": ["{{$out}}"]}]}
API
) 中调用:{"paths": [{"path": "/search","method": "GET","process": "models.user.Get","in": [":params"],"out": {"status": 200,"type": "application/json"}}]}
GET /api/user/search?withs=manu,mother,addresses&where.status.eq=enabled&order=id.desc&select=id,name,mobile,status&limit=2
models/category.mod.yao
文件,写入以下内容:{"name": "书籍分类","table": {"name": "category","comment": "书籍分类"},"columns": [{"label": "ID","name": "id","type": "ID","comment": "ID","primary": true},{"label": "父级id","name": "parent_id","type": "integer","nullable": true},{"label": "分类名称","name": "name","type": "string","length": 128,"index": true}],"relations": {"book": {"type": "hasMany","model": "book","key": "category_id","foreign": "id","query": {}},"parent": {"type": "hasOne","model": "category","key": "id","foreign": "parent_id","query": {}}},"option": {"timestamps": true,"soft_deletes": true},"values": [{"id": 1,"parent_id": null,"name": "文史类"},{"id": 2,"parent_id": 1,"name": "历史"},{"id": 3,"parent_id": 1,"name": "古诗"},{"id": 4,"parent_id": null,"name": "理工类"},{"id": 5,"parent_id": 4,"name": "数学"},{"id": 6,"parent_id": 4,"name": "物理"}]}
function Get() {return Process("models.category.get", {wheres: [{ column: "parent_id", value: null }],});}
执行 yao run scripts.test.Get