From 8d0043cc781e7f292dc34535f363c4a3976c9836 Mon Sep 17 00:00:00 2001 From: Atharv <65293806+Atharv-Bobde@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:56:02 +0530 Subject: [PATCH] Added Null check in case schema.options['type'][0] is undefined --- lib/document.js | 1 + 1 file changed, 1 insertion(+) 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 };