From 35859fbb0a105d29595d021fdf3c68b9a0dc765a Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Tue, 15 Oct 2024 20:58:57 +0300 Subject: [PATCH 1/2] quering for range can be done as a single document, otherwise shows error too --- lib/handlers/on-search.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/handlers/on-search.js b/lib/handlers/on-search.js index 1a97422a..19afda7c 100644 --- a/lib/handlers/on-search.js +++ b/lib/handlers/on-search.js @@ -220,14 +220,10 @@ module.exports = server => (mailbox, options, session, callback) => { break; } let entry = !op - ? [ - { - $gte: value - }, - { - $lt: new Date(value.getTime() + 24 * 3600 * 1000) - } - ] + ? { + $gte: value, + $lt: new Date(value.getTime() + 24 * 3600 * 1000) + } : { [op]: value }; @@ -263,14 +259,10 @@ module.exports = server => (mailbox, options, session, callback) => { break; } let entry = !op - ? [ - { - $gte: value - }, - { - $lt: new Date(value.getTime() + 24 * 3600 * 1000) - } - ] + ? { + $gte: value, + $lt: new Date(value.getTime() + 24 * 3600 * 1000) + } : { [op]: value }; @@ -279,7 +271,7 @@ module.exports = server => (mailbox, options, session, callback) => { hdate: !ne ? entry : { - $not: entry + $not: {} } }; From 255ff2fda69d01bd01ff66283177d097aedcf10c Mon Sep 17 00:00:00 2001 From: Nikolai Ovtsinnikov Date: Tue, 15 Oct 2024 21:00:47 +0300 Subject: [PATCH 2/2] fix buggy typo introduced in last commit --- lib/handlers/on-search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/handlers/on-search.js b/lib/handlers/on-search.js index 19afda7c..c889de41 100644 --- a/lib/handlers/on-search.js +++ b/lib/handlers/on-search.js @@ -271,7 +271,7 @@ module.exports = server => (mailbox, options, session, callback) => { hdate: !ne ? entry : { - $not: {} + $not: entry } };