Software /
code /
prosody
Changeset
7152:ca64255bf7cd
storagemanager: Add set_keys method to map store shim
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 09 Feb 2016 16:54:56 +0100 |
parents | 7151:584d5229cb91 |
children | 7153:89fa66d4e502 |
files | core/storagemanager.lua |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/core/storagemanager.lua Fri Aug 08 12:38:35 2014 +0200 +++ b/core/storagemanager.lua Tue Feb 09 16:54:56 2016 +0100 @@ -118,6 +118,23 @@ current[key] = data; return self.keyval_store:set(username, current); end; + set_keys = function (self, username, keydatas) + local current, err = self.keyval_store:get(username); + if current == nil then + if err then + return nil, err; + else + current = keydatas; + end + else + for k,v in pairs(keydatas) do + if v == self.remove then v = nil; end + current[k] = v; + end + end + return self.keyval_store:set(username, current); + end; + remove = {}; }; }