aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_memory.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-06-12 16:55:35 +0100
committerMatthew Wild <mwild1@gmail.com>2020-06-12 16:55:35 +0100
commit0919bb30d392aabf24ff9e35792c2a9ee1666aa0 (patch)
treea9f8657bc3fd1a166f49c958671e5b2a86f0f72a /plugins/mod_storage_memory.lua
parent371d05a0c6f7a9353155588d617a1efd468fd9d0 (diff)
downloadprosody-0919bb30d392aabf24ff9e35792c2a9ee1666aa0.tar.gz
prosody-0919bb30d392aabf24ff9e35792c2a9ee1666aa0.zip
mod_storage_internal, mod_storage_memory: Add support for query.before
Previously returned all results.
Diffstat (limited to 'plugins/mod_storage_memory.lua')
-rw-r--r--plugins/mod_storage_memory.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/mod_storage_memory.lua b/plugins/mod_storage_memory.lua
index 67598416..d71dc0f0 100644
--- a/plugins/mod_storage_memory.lua
+++ b/plugins/mod_storage_memory.lua
@@ -101,7 +101,7 @@ function archive_store:find(username, query)
return function () end;
end
local count = nil;
- local i = 0;
+ local i, last_key = 0;
if query then
items = array():append(items);
if query.key then
@@ -142,6 +142,8 @@ function archive_store:find(username, query)
return nil, "item-not-found";
end
end
+ elseif query.before then
+ last_key = query.before;
elseif query.after then
local found = false;
for j = 1, #items do
@@ -162,7 +164,7 @@ function archive_store:find(username, query)
return function ()
i = i + 1;
local item = items[i];
- if not item then return; end
+ if not item or (last_key and item.key == last_key) then return; end
return item.key, item.value(), item.when, item.with;
end, count;
end