Last active
January 28, 2018 01:09
-
-
Save paragasu/c7f32dd6d154a08bfd53e12783c199fa to your computer and use it in GitHub Desktop.
Lua add member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- add name in the current database members list | |
function db.add_member(self, name) | |
local data, err = db:get('_security') | |
if not data then error(err) end | |
if not data.members then | |
data.members = {} | |
data.members.names = { name } | |
else | |
local current_members = data.members.names | |
data.members.names = table.insert(current_members, name) | |
end | |
data._id = '_security' | |
return db:put(data) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment