|
|
|
@ -482,7 +482,7 @@ describe('Model', function () { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('Logical operators $or, $and', function () { |
|
|
|
|
describe('Logical operators $or, $and, $not', function () { |
|
|
|
|
|
|
|
|
|
it('Any of the subqueries should match for an $or to match', function () { |
|
|
|
|
model.match({ hello: 'world' }, { $or: [ { hello: 'pluton' }, { hello: 'world' } ] }).should.equal(true); |
|
|
|
@ -499,6 +499,11 @@ describe('Model', function () { |
|
|
|
|
model.match({ hello: 'world', age: 15 }, { $and: [ { hello: 'pluton' }, { age: { $lt: 20 } } ] }).should.equal(false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('Subquery should not match for a $not to match', function () { |
|
|
|
|
model.match({ a: 5, b: 10 }, { a: 5 }).should.equal(true); |
|
|
|
|
model.match({ a: 5, b: 10 }, { $not: { a: 5 } }).should.equal(false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('Logical operators are all top-level, only other logical operators can be above', function () { |
|
|
|
|
(function () { model.match({ a: { b: 7 } }, { a: { $or: [ { b: 5 }, { b: 7 } ] } })}).should.throw(); |
|
|
|
|
model.match({ a: { b: 7 } }, { $or: [ { "a.b": 5 }, { "a.b": 7 } ] }).should.equal(true); |
|
|
|
|