1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2024-12-28 18:38:20 +01:00
antd-lua-plugin/example-app/os/db/model.lua
2018-09-19 15:08:49 +02:00

20 lines
464 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" then
meta[k] = "NUMERIC"
else
meta[k] = "TEXT"
end
end
db:createTable(meta)
return db
end
return model