@@ -101,8 +101,8 @@ module.exports = function getSchemaTypes(model, schema, doc, path) {
101101 nestedPath . concat ( parts . slice ( 0 , p ) )
102102 ) ;
103103 if ( ret ) {
104- ret . $isUnderneathDocArray = ret . $isUnderneathDocArray ||
105- ! foundschema . schema . $isSingleNested ;
104+ ret . $parentSchemaDocArray = ret . $parentSchemaDocArray ||
105+ ( foundschema . schema . $isSingleNested ? null : foundschema ) ;
106106 }
107107 return ret ;
108108 }
@@ -117,10 +117,10 @@ module.exports = function getSchemaTypes(model, schema, doc, path) {
117117 nestedPath . concat ( parts . slice ( 0 , p ) )
118118 ) ;
119119 if ( _ret != null ) {
120- _ret . $isUnderneathDocArray = _ret . $isUnderneathDocArray ||
121- ! foundschema . schema . $isSingleNested ;
122- if ( _ret . $isUnderneathDocArray ) {
123- ret . $isUnderneathDocArray = true ;
120+ _ret . $parentSchemaDocArray = _ret . $parentSchemaDocArray ||
121+ ( foundschema . schema . $isSingleNested ? null : foundschema ) ;
122+ if ( _ret . $parentSchemaDocArray ) {
123+ ret . $parentSchemaDocArray = _ret . $parentSchemaDocArray ;
124124 }
125125 ret . push ( _ret ) ;
126126 }
@@ -135,8 +135,8 @@ module.exports = function getSchemaTypes(model, schema, doc, path) {
135135 ) ;
136136
137137 if ( ret ) {
138- ret . $isUnderneathDocArray = ret . $isUnderneathDocArray ||
139- ! foundschema . schema . $isSingleNested ;
138+ ret . $parentSchemaDocArray = ret . $parentSchemaDocArray ||
139+ ( foundschema . schema . $isSingleNested ? null : foundschema ) ;
140140 }
141141 return ret ;
142142 }
@@ -188,10 +188,6 @@ module.exports = function getSchemaTypes(model, schema, doc, path) {
188188 nestedPath . concat ( parts . slice ( 0 , p ) )
189189 ) ;
190190
191- if ( ret ) {
192- ret . $isUnderneathDocArray = ret . $isUnderneathDocArray ||
193- ! model . schema . $isSingleNested ;
194- }
195191 return ret ;
196192 }
197193 }
@@ -212,8 +208,8 @@ module.exports = function getSchemaTypes(model, schema, doc, path) {
212208 ) ;
213209
214210 if ( ret != null ) {
215- ret . $isUnderneathDocArray = ret . $isUnderneathDocArray ||
216- ! schema . $isSingleNested ;
211+ ret . $parentSchemaDocArray = ret . $parentSchemaDocArray ||
212+ ( schema . $isSingleNested ? null : schema ) ;
217213 return ret ;
218214 }
219215 }
0 commit comments