From 41f44a0f374ce2f264bc5cfcf37fae0279559351 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Fri, 5 Jul 2024 17:26:56 -0500 Subject: [PATCH] fix: $pull continue if key does not exist --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 6939026..cc7bd65 100644 --- a/src/index.js +++ b/src/index.js @@ -257,6 +257,8 @@ if (!exists) newObject[keys[i]].push(value) } else if (operator === '$pull') { + if (!newObject[keys[i]]) + continue if (Array.isArray(value)) { newObject[keys[i]] = newObject[keys[i]].filter(item => !Array.isArray(item) || !isEqualArray(item, value)); } else if (typeof value === 'object' && value !== null) {