Permalink
Browse files

backport string regex $options to 2.x

  • Loading branch information...
1 parent de79261 commit eeef07215fb0d6cc2282870c4de4e7b905f94bac @aheckmann aheckmann committed May 15, 2012
Showing with 16 additions and 0 deletions.
  1. +1 −0 lib/schema/string.js
  2. +15 −0 test/model.querying.test.js
@@ -157,6 +157,7 @@ SchemaString.prototype.$conditionalHandlers = {
, '$lte': handleSingle
, '$all': handleArray
, '$regex': handleSingle
+ , '$options': handleSingle
};
SchemaString.prototype.castForQuery = function ($conditional, val) {
@@ -2371,4 +2371,19 @@ module.exports = {
S.find({ _id: s._id }).exec(done);
});
},
+
+ 'regex with options': function () {
+ var db = start()
+ , B = db.model('BlogPostB', collection)
+
+ var post = new B({ title: '$option queries' });
+ post.save(function (err) {
+ should.strictEqual(null, err);
+ B.findOne({ title: { $regex: ' QUERIES$', $options: 'i' }}, function (err, doc) {
+ db.close();
+ should.strictEqual(null, err, err && err.stack);
+ doc.id.should.eql(post.id);
+ })
+ });
+ }
};

0 comments on commit eeef072

Please sign in to comment.