summaryrefslogtreecommitdiff
path: root/server/db.lua
blob: cc28b7769cc14a423e2a681e7faa0a6b49a9de74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
local lmdb = require'lmdb'
local env = assert(lmdb.open('data',{maxdbs=16}))
local function get_db(dbname, writeable)
	-- shortcut
	if writeable == nil then writeable = false end
	local txn = assert(env:txn_begin(writeable))
	local the_db = assert(txn:open(dbname))
	return txn,the_db
end
local function txn(writeable)
	return assert(env:txn_begin(writeable))
end


return {
	env=env,
	txn=txn,
	get_db=get_db,
}