diff options
author | Kim Alvefur <zash@zash.se> | 2012-09-21 17:24:06 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-09-21 17:24:06 +0200 |
commit | 3b3af5c75ef16eafb104e518a87a532b50bb5fc7 (patch) | |
tree | db94260d13d565e7d2853f0656bea55fdfa34d32 /plugins/mod_storage_sql.lua | |
parent | 196022f3f5e88c241fdf7fafe3affd2f8912036d (diff) | |
download | prosody-3b3af5c75ef16eafb104e518a87a532b50bb5fc7.tar.gz prosody-3b3af5c75ef16eafb104e518a87a532b50bb5fc7.zip |
mod_storage_sql: Add support for iterating over users with data in a store
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r-- | plugins/mod_storage_sql.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index c9a45fca..f6fa94e7 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -298,6 +298,17 @@ function keyval_store:set(username, data) 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 ""); |