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/model.lua

20 lines
464 B
Lua
Raw Normal View History

2018-09-19 15:08:49 +02:00
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