diff --git a/lib/schema.js b/lib/schema.js index 1aac5594522..2504c14059c 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -672,16 +672,17 @@ Schema.prototype.path = function(path, obj) { let arrayPath = path; let _schemaType = schemaType; - let toAdd = []; + const toAdd = []; while (_schemaType.$isMongooseArray) { arrayPath = arrayPath + '.$'; // Skip arrays of document arrays if (_schemaType.$isMongooseDocumentArray) { - toAdd = []; - break; + _schemaType = _schemaType.$embeddedSchemaType.clone(); + } else { + _schemaType = _schemaType.caster.clone(); } - _schemaType = _schemaType.caster.clone(); + _schemaType.path = arrayPath; toAdd.push(_schemaType); }