Skip to content

Commit

Permalink
Merge pull request #84 from flyvictor/WEB-5601-deep-query-modificator…
Browse files Browse the repository at this point in the history
…s-rewrite

WEB-5601 deep query modificators rewrite
  • Loading branch information
jesuscript committed Oct 15, 2014
2 parents a247833 + ed93457 commit d0e1906
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/adapters/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ adapter.findMany = function(model, query, projection) {
}else if(key === 'or' || key === 'and') {
query['$' + key] = _.map(val, parseQuery);
delete query[key];
}else if(key === '$or' || key === '$and'){
query[key] = _.map(val, parseQuery);
}
});

Expand Down
22 changes: 22 additions & 0 deletions test/fortune-mongodb/mongodb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,28 @@ module.exports = function(options){
done();
});
});
it('should deeply parse nested $and, $or, or, and queries', function(done){
var query = {
$or: [{
or: [{
$and: [{
and: [{
name: {
regex: 'WALLY',
options: 'i'
}
}]
}]
}]
}]
};
adapter.findMany('person', query)
.then(function(docs){
docs.length.should.equal(1);
docs[0].name.should.equal('Wally');
done();
});
});
});
});

Expand Down

0 comments on commit d0e1906

Please sign in to comment.