diff options
| author | the lemons <citrons@mondecitronne.com> | 2023-04-07 03:29:49 -0500 |
|---|---|---|
| committer | the lemons <citrons@mondecitronne.com> | 2023-04-07 03:29:49 -0500 |
| commit | 1becf46aea2ab522c82212d1c74732a77b3142a9 (patch) | |
| tree | d2861a0584dc68b6271408fddf0cb03c4eefc76d /db.lua | |
intial commit
Diffstat (limited to 'db.lua')
| -rw-r--r-- | db.lua | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +local lmdb = require 'lmdb' + +local M = {} + +local db + +function M.get() + if not db then + db = assert(lmdb.open("data", {maxdbs = 256})) + end + local txn = db:txn_begin(true) + local meta = txn:open("meta", true) + if not meta.version then + version = 1 + end + txn:open("users", true) + txn:open("usernames", true) + txn:open("emails", true) + txn:commit() + return db +end + +function M.txn(write_enabled) + return M.get():txn_begin(write_enabled) +end + +M.next = lmdb.next + +return M |
