This commit is contained in:
robin
2022-04-12 03:06:19 +08:00
parent 344562baf4
commit f88b5e9325
6 changed files with 124 additions and 20 deletions
+11 -12
View File
@@ -5,19 +5,14 @@ module.exports = {
path : "/",
method : ["get", "post"],
middleware: [],
params : {},
params : {
"age": "int"
},
return : {},
controller: async (ctx, app) => {
console.log(ctx.request.body);
// app.err.ParameterException()
app.event.emit('test.event2')
const where = {
// id: 4
}
const data = {
// id: 1,
uid: "77",
}
// app.event.emit('test.event2')
// const User = await app.table("User").where(where).findAll()
// const User = await app.table("User").time(["2022-04-9", "2022-04-10"]).findAll()
// const User = await app.table("User").where(where).findOrCreate(data)
@@ -48,9 +43,13 @@ module.exports = {
// await app.table("User").where({id: 1032}).data({age: 2}).setInc() // 字段值+2
// const {res, value} = await app.table("User").where({id: 1032}).data({age: 2}).setDec(0) // 字段值-2,不能低于0,如果低于0返回false
// const {res, value} = await app.table("User").where({id: 1032}).data({age: 2}).setDec(0,10) // 字段值-2,不能低于0,如果低于0设置为10
const {res, value} = await app.table("User").where({id: 1032}).data({age: 2}).setInc(20, 10) // 字段值+2,不能大于20,如果大于20设置为10
// const {res, value} = await app.table("User").where({id: 1032}).data({age: 2}).setInc(20, 10) // 字段值+2,不能大于20,如果大于20设置为10
// const res = await app.table("User").count() // 统计
// const res = await app.table("User").data("age").sum() // 求和
// const res = await app.table("User").data("age").max() // 查询最大值
// const res = await app.table("User").data("age").min() // 查询最小值
ctx.body = {res, value}
ctx.body = {}
}
}
+4
View File
@@ -0,0 +1,4 @@
'use strict';
const bodyParser = require('koa-bodyparser')
// 错误处理
module.exports = bodyParser()
Binary file not shown.