Skip to content

Commit

Permalink
fix: process key[] as $push
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Feb 18, 2024
1 parent ee06f01 commit 5628edf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ function createUpdate(update, options, data, isGlobal) {
options.upsert = data.upsert
if (data.$upsert)
options.upsert = data.$upsert
if (data.$update)
delete data.$update

Object.keys(data).forEach(key => {
if (isGlobal && !key.startsWith('$') || key === '_id')
Expand Down Expand Up @@ -560,6 +562,8 @@ function createUpdate(update, options, data, isGlobal) {
}
if (!key.startsWith('$'))
operator = '$push'
if (key.endsWith('[]'))
key = key.replace('[]', '');
}

let operators = ['$rename', '$inc', '$push', '$each', '$splice', '$unset', '$delete', '$slice', '$pop', '$shift', '$addToSet', '$pull', '$currentDate']
Expand Down

0 comments on commit 5628edf

Please sign in to comment.