up
This commit is contained in:
+31
-3
@@ -6,7 +6,7 @@ module.exports = {
|
||||
method : ["get", "post"],
|
||||
middleware: [],
|
||||
params : {
|
||||
"age": "int"
|
||||
"age": "int?"
|
||||
},
|
||||
return : {},
|
||||
controller: async (ctx, app) => {
|
||||
@@ -19,7 +19,7 @@ module.exports = {
|
||||
// const {count, rows} = await app.table("User").where(where).findAndCountAll()
|
||||
// const User = await app.table("User").save(data)
|
||||
// const res = {
|
||||
// "创建单个数据" : await app.table("User").data({uid: "6666"}).save(),
|
||||
// // "创建单个数据" : await app.table("User").data({uid: "6666"}).save(),
|
||||
// "查询单个数据" : await app.table("User").where({id: 2}).find(),
|
||||
// "查询单个数据,不存在就创建" : await app.table("User").where({id: 999}).data({uid: "6666"}).findOrCreate(),
|
||||
// "查询所有数据" : await app.table("User").where({uid: "6666"}).findAll(),
|
||||
@@ -49,7 +49,35 @@ module.exports = {
|
||||
// const res = await app.table("User").data("age").max() // 查询最大值
|
||||
// const res = await app.table("User").data("age").min() // 查询最小值
|
||||
|
||||
const res = await app.jsonTasks([
|
||||
{"table": "User", "where": {id: 999}, "find": "", "as": "user_data"},//as 设置结果别名
|
||||
// {
|
||||
// "table" : "UserInfo",
|
||||
// "data" : {
|
||||
// "phone": "13126000000",
|
||||
// "uid": "$as.user_data.id",//根据别名 user_data 返回的结果中的id值作为数据保存
|
||||
// }, "save": ""
|
||||
// },
|
||||
{
|
||||
"table" : "UserInfo",
|
||||
"where" : {
|
||||
"uid": "$as.user_data.id",//根据别名 user_data 返回的结果中的id值作为条件查询
|
||||
}, "find": ""
|
||||
},
|
||||
|
||||
ctx.body = {}
|
||||
// {"table": "User", "data": "age", "min": ""},
|
||||
// {
|
||||
// "as": "user_list", "jsonTasks": [ //整个任务设置别名
|
||||
// {"setTransaction": ""}, // 开始事务
|
||||
// {"table": "User", "data": "age", "sum": ""},
|
||||
// {"table": "User", "data": "age", "max": ""},
|
||||
// {"table": "User", "data": "age", "min": ""},
|
||||
// {"commitTransaction": ""}, //提交事务
|
||||
// ]
|
||||
// },
|
||||
])
|
||||
|
||||
|
||||
ctx.body = {res}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
doc : "用户信息表",
|
||||
model: {
|
||||
uid : {type: "STRING", comment: '用户id'},
|
||||
phone: {type: "STRING", comment: '手机号', defaultValue: null,},
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user