Created operator

pull/2/head
Louis Chatriot 12 years ago
parent cd739492d3
commit 4256632f72
  1. 2
      lib/model.js
  2. 2
      test/model.test.js

@ -344,7 +344,7 @@ function matchQueryPart (obj, queryKey, queryValue) {
, i , i
; ;
// Check if query begins with an operator and we need to rewrite it // Query part begins with a logical operator: apply it
if (queryKey[0] === '$') { if (queryKey[0] === '$') {
if (!matcherFunctions[queryKey]) { throw "Unknown query operator " + queryKey; } if (!matcherFunctions[queryKey]) { throw "Unknown query operator " + queryKey; }

@ -489,7 +489,7 @@ describe('Model', function () {
}); });
it('Logical operators are all top-level, only other logical operators can be above', function () { it('Logical operators are all top-level, only other logical operators can be above', function () {
model.match({ a: { b: 7 } }, { a: { $or: [ { b: 5 }, { b: 7 } ] } }).should.equal(false); (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); model.match({ a: { b: 7 } }, { $or: [ { "a.b": 5 }, { "a.b": 7 } ] }).should.equal(true);
}); });

Loading…
Cancel
Save