aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-09-28 22:04:04 +0200
committerKim Alvefur <zash@zash.se>2013-09-28 22:04:04 +0200
commite8380a3cd2a3747554ac3da1b1c106344b484f0b (patch)
tree27357d4de2658656f54dcdd5b941a6493b76b911
parentc9f9fdd69ca8fa710a9a8467f289e4ca7bb0b94e (diff)
downloadprosody-e8380a3cd2a3747554ac3da1b1c106344b484f0b.tar.gz
prosody-e8380a3cd2a3747554ac3da1b1c106344b484f0b.zip
mod_storage_sql2: Add method for deleting items from archives with same syntax as :find()
-rw-r--r--plugins/mod_storage_sql2.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua
index 1ce8c204..174bad78 100644
--- a/plugins/mod_storage_sql2.lua
+++ b/plugins/mod_storage_sql2.lua
@@ -340,6 +340,21 @@ function archive_store:find(username, query)
end, total;
end
+function archive_store:delete(username, query)
+ query = query or {};
+ local user,store = username,self.store;
+ return engine:transaction(function()
+ local sql_query = "DELETE FROM `prosodyarchive` WHERE %s;";
+ local args = { host, user or "", store, };
+ local where = { "`host` = ?", "`user` = ?", "`store` = ?", };
+ archive_where(query, args, where);
+ archive_where_id_range(query, args, where);
+ sql_query = sql_query:format(t_concat(where, " AND "));
+ module:log("debug", sql_query);
+ return engine:delete(sql_query, unpack(args));
+ end);
+end
+
local stores = {
keyval = keyval_store;
archive = archive_store;