Skip to content

Commit

Permalink
fix adding range
Browse files Browse the repository at this point in the history
  • Loading branch information
Golan Hallel committed Nov 16, 2022
1 parent 6d7fc9c commit 1fdc142
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/MongoDB/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ class Query {
addDatesRange(key, range) {
let from;
let to;
this._map[key] = {};
if (range?.from) {
from = new Date(range?.from).getTime();
this._map[key].$gte = from;
}
if (range?.from || range?.to) {
this._map[key] = {};
if (range?.from) {
from = new Date(range?.from).getTime();
this._map[key].$gte = from;
}

if (range?.to) {
to = new Date(range?.to).getTime();
this._map[key].$lt = to;
if (range?.to) {
to = new Date(range?.to).getTime();
this._map[key].$lt = to;
}
}
return this;
}
Expand Down

0 comments on commit 1fdc142

Please sign in to comment.