Skip to content

Commit

Permalink
refactor(schema): add array.$, array.$.$ subpaths for nested arrays
Browse files Browse the repository at this point in the history
Fix #6405
  • Loading branch information
vkarpov15 committed Nov 25, 2019
1 parent cfbaf0f commit 51c6776
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 51c6776

Please sign in to comment.