Skip to content

Commit

Permalink
Test case for #2031
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 5, 2014
1 parent d71f83e commit 8a53b86
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions test/model.field.selection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,33 @@ describe('model field selection', function(){
assert.ok(/ ids/.test(err));
assert.ok(/ ids2/.test(err));
done()
})
})
})
})
})
});
});
});
});

it('works with $ positional in select (gh-2031)', function(done) {
var db = start();

var postSchema = new Schema({
tags: [{ tag: String, count: 0 }]
});

var Post = db.model('gh-2031', postSchema, 'gh-2031');
Post.create({ tags: [{ tag: 'bacon', count: 2 }, { tag: 'eggs', count: 3 }] }, function(error, post) {
assert.ifError(error);
Post.findOne({ 'tags.tag': 'eggs' }, { 'tags.$': 1 }, function(error, post) {
assert.ifError(error);
post.tags[0].count = 1;
post.save(function(error, post) {
assert.ok(error);
db.close();
done();
});
});
});
});
});

it('selecting an array of docs applies defaults properly (gh-1108)', function(done){
var db = start()
Expand Down

0 comments on commit 8a53b86

Please sign in to comment.