mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-12-27 09:58:20 +01:00
20 lines
488 B
Lua
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 |