# HG changeset patch # User Kim Alvefur # Date 1348241046 -7200 # Node ID 429c8eeea0359328d5c5c449c2071e4a72564cc4 # Parent 688aeac0012ac37d8891f1a6dc364e0724be9bd6 mod_storage_sql: Add support for iterating over users with data in a store diff -r 688aeac0012a -r 429c8eeea035 plugins/mod_storage_sql.lua --- a/plugins/mod_storage_sql.lua Fri Sep 21 17:23:08 2012 +0200 +++ b/plugins/mod_storage_sql.lua Fri Sep 21 17:24:06 2012 +0200 @@ -298,6 +298,17 @@ end if success then return ret, err; else return rollback(nil, ret); end end +function keyval_store:users() + local stmt, err = dosql("SELECT DISTINCT `user` FROM `prosody` WHERE `host`=? AND `store`=?", host, self.store); + if not stmt then + return rollback(nil, err); + end + local next = stmt:rows(); + return commit(function() + local row = next(); + return row and row[1]; + end); +end local function map_store_get(key) local stmt, err = getsql("SELECT * FROM `prosody` WHERE `host`=? AND `user`=? AND `store`=? AND `key`=?", key or "");