Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Commit 2744a44

Browse files
committed
COMPASS-3498: Handle in range queries
1 parent 2cd6d44 commit 2744a44

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/inValueRange.js

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ const inValueRange = (field, d) => {
4747
},
4848
$exists: function(a, b) {
4949
return (a || b);
50+
},
51+
$eq: function(a, b) {
52+
return a === b;
5053
}
5154
};
5255

test/inValueRange.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,20 @@ describe('inValueRange [Util]', () => {
270270
});
271271
});
272272

273+
describe('ranges with $eq', () => {
274+
beforeEach(() => {
275+
query = {$eq: 5};
276+
});
277+
278+
it('should detect a match for a range', () => {
279+
expect(inValueRange(query, {value: 5, dx: 5})).to.equal('partial');
280+
});
281+
282+
it('should detect a match for single value', () => {
283+
expect(inValueRange(query, {value: 10, dx: 0})).to.equal('no');
284+
});
285+
});
286+
273287
describe('non-numeric types', () => {
274288
it('should work for dates', () => {
275289
query = {$gte: new Date('2011-01-01'), $lte: new Date('2013-01-01')};

0 commit comments

Comments
 (0)