Comparison

plugins/mod_storage_sql.lua @ 10680:19692fc5c106

storagemanager, mod_storage_sql: Rename methods to :get_all() and :delete_all()
author Matthew Wild <mwild1@gmail.com>
date Wed, 11 Mar 2020 16:32:41 +0000
parent 10677:0054aec3e8c5
child 10701:929c95e518f0
comparison
equal deleted inserted replaced
10679:b50b1eae711c 10680:19692fc5c106
228 end); 228 end);
229 if not ok then return nil, result; end 229 if not ok then return nil, result; end
230 return result; 230 return result;
231 end 231 end
232 232
233 function map_store:find_key(key) 233 function map_store:get_all(key)
234 if type(key) ~= "string" or key == "" then 234 if type(key) ~= "string" or key == "" then
235 return nil, "find_key only supports non-empty string keys"; 235 return nil, "get_all only supports non-empty string keys";
236 end 236 end
237 local ok, result = engine:transaction(function() 237 local ok, result = engine:transaction(function()
238 local query = [[ 238 local query = [[
239 SELECT "user", "type", "value" 239 SELECT "user", "type", "value"
240 FROM "prosody" 240 FROM "prosody"
256 end); 256 end);
257 if not ok then return nil, result; end 257 if not ok then return nil, result; end
258 return result; 258 return result;
259 end 259 end
260 260
261 function map_store:delete_key(key) 261 function map_store:delete_all(key)
262 if type(key) ~= "string" or key == "" then 262 if type(key) ~= "string" or key == "" then
263 return nil, "delete_key only supports non-empty string keys"; 263 return nil, "delete_all only supports non-empty string keys";
264 end 264 end
265 local ok, result = engine:transaction(function() 265 local ok, result = engine:transaction(function()
266 local delete_sql = [[ 266 local delete_sql = [[
267 DELETE FROM "prosody" 267 DELETE FROM "prosody"
268 WHERE "host"=? AND "store"=? AND "key"=?; 268 WHERE "host"=? AND "store"=? AND "key"=?;