1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2024-12-29 10:48:21 +01:00
antd-lua-plugin/example-app/os/db/select.lua
2018-09-19 15:08:49 +02:00

20 lines
575 B
Lua

auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
if(rq ~= nil and rq.table ~= nil) then
local model = require("db.model").get(SESSION.iotos_user,rq.table, nil)
local ret
if model == nil then
fail("Cannot get table metadata:"..rq.table)
else
if(rq.cond == nil ) then
model:close()
return fail("Unknow condition")
else
ret = model:find(rq.cond)
end
model:close()
result(ret)
end
else
fail("Unknown database request")
end