@@ -621,6 +621,36 @@ describe('model', function() {
621
621
} ) ;
622
622
} ) ;
623
623
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
+
624
654
it ( 'embedded discriminators with $push (gh-5009)' , function ( done ) {
625
655
var eventSchema = new Schema ( { message : String } ,
626
656
{ discriminatorKey : 'kind' , _id : false } ) ;
0 commit comments