Comparison

plugins/mod_storage_internal.lua @ 8022:05e201468f27

mod_storage_internal: Add support for removing archived items
author Kim Alvefur <zash@zash.se>
date Fri, 31 Mar 2017 17:48:50 +0200
parent 8021:83f18982bcfd
child 8023:5a9d491cc714
comparison
equal deleted inserted replaced
8021:83f18982bcfd 8022:05e201468f27
118 item = st.deserialize(item); 118 item = st.deserialize(item);
119 return key, item, when, with; 119 return key, item, when, with;
120 end, count; 120 end, count;
121 end 121 end
122 122
123 function archive:delete(username, query)
124 if not query or next(query) == nil then
125 return datamanager.list_store(username, host, self.store, nil);
126 end
127 for k in pairs(query) do
128 if k ~= "end" then return nil, "unsupported-query-field"; end
129 end
130 local items, err = datamanager.list_load(username, host, self.store);
131 if not items then return items, err; end
132 items = array(items);
133 items:filter(function (item)
134 return item.when > query["end"];
135 end);
136 local count = #items;
137 local ok, err = datamanager.list_store(username, host, self.store, items);
138 if not ok then return ok, err; end
139 return count;
140 end
141
123 module:provides("storage", driver); 142 module:provides("storage", driver);