1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-27 01:48:21 +01:00
antd-web-apps/os/libs/dbmodel.lua
2018-09-12 18:31:25 +02:00

20 lines
488 B
Lua

local model = {}
model.get = function(name, tbl, data)
local db = DBModel:new{db = name, name=tbl}
db:open()
if db:available() then return db end
if data == nil then return nil end
local meta = {}
--print(JSON.encode(data))
for k,v in pairs(data) do
if type(v) == "number" or type(v) == "boolean" then
meta[k] = "NUMERIC"
else
meta[k] = "TEXT"
end
end
db:createTable(meta)
return db
end
return model