Software /
code /
prosody
Changeset
5154:429c8eeea035
mod_storage_sql: Add support for iterating over users with data in a store
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 21 Sep 2012 17:24:06 +0200 |
parents | 5153:688aeac0012a |
children | 5155:a207d4bff5a4 |
files | plugins/mod_storage_sql.lua |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 "");