File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,28 @@ describe('model', function() {
470470 } ) ;
471471 } ) ;
472472
473+ it ( 'skips automatic indexing on childSchema if autoIndex: false (gh-9150)' , function ( ) {
474+ const nestedSchema = mongoose . Schema ( {
475+ name : { type : String , index : true }
476+ } , { autoIndex : false } ) ;
477+ const schema = mongoose . Schema ( {
478+ nested : nestedSchema ,
479+ top : { type : String , index : true }
480+ } ) ;
481+ let Model ;
482+
483+ return Promise . resolve ( ) .
484+ then ( ( ) => {
485+ Model = db . model ( 'Model' , schema ) ;
486+ return Model . init ( ) ;
487+ } ) .
488+ then ( ( ) => Model . listIndexes ( ) ) .
489+ then ( indexes => {
490+ assert . equal ( indexes . length , 2 ) ;
491+ assert . deepEqual ( indexes [ 1 ] . key , { top : 1 } ) ;
492+ } ) ;
493+ } ) ;
494+
473495 describe ( 'discriminators with unique' , function ( ) {
474496 this . timeout ( 5000 ) ;
475497
You can’t perform that action at this time.
0 commit comments