# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1557066361 -7200
# Node ID b6b5b9d7417d82625adc73f748fc99e48aa34588
# Parent  55f5588d71c61c7b1ffd7fcccd66958e06d6b917
mod_storage_sql: Add support for iterating over users in archive stores

diff -r 55f5588d71c6 -r b6b5b9d7417d plugins/mod_storage_sql.lua
--- a/plugins/mod_storage_sql.lua	Sun May 05 16:07:16 2019 +0200
+++ b/plugins/mod_storage_sql.lua	Sun May 05 16:26:01 2019 +0200
@@ -509,6 +509,19 @@
 	return ok and stmt:affected(), stmt;
 end
 
+function archive_store:users()
+	local ok, result = engine:transaction(function()
+		local select_sql = [[
+		SELECT DISTINCT "user"
+		FROM "prosodyarchive"
+		WHERE "host"=? AND "store"=?;
+		]];
+		return engine:select(select_sql, host, self.store);
+	end);
+	if not ok then error(result); end
+	return iterator(result);
+end
+
 local stores = {
 	keyval = keyval_store;
 	map = map_store;