Comparison

plugins/mod_storage_sql2.lua @ 5848:06156bfd4eaf

mod_storage_sql2: Add method for deleting items from archives with same syntax as :find()
author Kim Alvefur <zash@zash.se>
date Sat, 28 Sep 2013 22:04:04 +0200
parent 5847:6aaa7ad4463c
child 5881:12d12bda4b8c
comparison
equal deleted inserted replaced
5847:6aaa7ad4463c 5848:06156bfd4eaf
338 return row[1], deserialize(row[2], row[3]), row[4]; 338 return row[1], deserialize(row[2], row[3]), row[4];
339 end 339 end
340 end, total; 340 end, total;
341 end 341 end
342 342
343 function archive_store:delete(username, query)
344 query = query or {};
345 local user,store = username,self.store;
346 return engine:transaction(function()
347 local sql_query = "DELETE FROM `prosodyarchive` WHERE %s;";
348 local args = { host, user or "", store, };
349 local where = { "`host` = ?", "`user` = ?", "`store` = ?", };
350 archive_where(query, args, where);
351 archive_where_id_range(query, args, where);
352 sql_query = sql_query:format(t_concat(where, " AND "));
353 module:log("debug", sql_query);
354 return engine:delete(sql_query, unpack(args));
355 end);
356 end
357
343 local stores = { 358 local stores = {
344 keyval = keyval_store; 359 keyval = keyval_store;
345 archive = archive_store; 360 archive = archive_store;
346 }; 361 };
347 362