Skip to content

Commit

Permalink
test(discriminator): repro #5859
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 8, 2017
1 parent cc84026 commit 7c355b0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/model.discriminator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,36 @@ describe('model', function() {
});
});

it('with $meta projection (gh-5859)', function() {
var eventSchema = new Schema({ eventField: String }, { id: false });
var Event = db.model('gh5859', eventSchema);

var trackSchema = new Schema({ trackField: String });
var Track = Event.discriminator('gh5859_0', trackSchema);

var trackedItem = new Track({
trackField: 'trackField',
eventField: 'eventField',
});

return trackedItem.save().
then(function() {
return Event.find({}).select({ score: { $meta: 'textScore' } });
}).
then(function(docs) {
assert.equal(docs.length, 1);
assert.equal(docs[0].trackField, 'trackField');
}).
then(function() {
return Track.find({}).select({ score: { $meta: 'textScore' } });
}).
then(function(docs) {
assert.equal(docs.length, 1);
assert.equal(docs[0].trackField, 'trackField');
assert.equal(docs[0].eventField, 'eventField');
});
});

it('embedded discriminators with $push (gh-5009)', function(done) {
var eventSchema = new Schema({ message: String },
{ discriminatorKey: 'kind', _id: false });
Expand Down

0 comments on commit 7c355b0

Please sign in to comment.