Skip to content

Commit 7c355b0

Browse files
committed
test(discriminator): repro #5859
1 parent cc84026 commit 7c355b0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/model.discriminator.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,36 @@ describe('model', function() {
621621
});
622622
});
623623

624+
it('with $meta projection (gh-5859)', function() {
625+
var eventSchema = new Schema({ eventField: String }, { id: false });
626+
var Event = db.model('gh5859', eventSchema);
627+
628+
var trackSchema = new Schema({ trackField: String });
629+
var Track = Event.discriminator('gh5859_0', trackSchema);
630+
631+
var trackedItem = new Track({
632+
trackField: 'trackField',
633+
eventField: 'eventField',
634+
});
635+
636+
return trackedItem.save().
637+
then(function() {
638+
return Event.find({}).select({ score: { $meta: 'textScore' } });
639+
}).
640+
then(function(docs) {
641+
assert.equal(docs.length, 1);
642+
assert.equal(docs[0].trackField, 'trackField');
643+
}).
644+
then(function() {
645+
return Track.find({}).select({ score: { $meta: 'textScore' } });
646+
}).
647+
then(function(docs) {
648+
assert.equal(docs.length, 1);
649+
assert.equal(docs[0].trackField, 'trackField');
650+
assert.equal(docs[0].eventField, 'eventField');
651+
});
652+
});
653+
624654
it('embedded discriminators with $push (gh-5009)', function(done) {
625655
var eventSchema = new Schema({ message: String },
626656
{ discriminatorKey: 'kind', _id: false });

0 commit comments

Comments
 (0)