diff --git a/lib/document.js b/lib/document.js index 78b6f58eff2..61a88edfe72 100644 --- a/lib/document.js +++ b/lib/document.js @@ -1388,6 +1388,7 @@ Document.prototype.$set = function $set(path, val, type, options) { if (schema.options && Array.isArray(schema.options[typeKey]) && schema.options[typeKey].length && + schema.options[typeKey][0] && schema.options[typeKey][0].ref && _isManuallyPopulatedArray(val, schema.options[typeKey][0].ref)) { popOpts = { [populateModelSymbol]: val[0].constructor };