diff --git a/lib/schema.js b/lib/schema.js index 73716ca7f20..c501792c529 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -2224,7 +2224,7 @@ Schema.prototype.virtual = function(name, options) { if (this.paths[cur] == null) { continue; } - + if (this.paths[cur].$isMongooseDocumentArray || this.paths[cur].$isSingleNested) { const remnant = parts.slice(i + 1).join('.'); this.paths[cur].schema.virtual(remnant, options);