@cocreate/mongodb 1.17.4 → 1.17.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/index.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.17.6](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.5...v1.17.6) (2024-02-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* process key[] as $push ([5628edf](https://github.com/CoCreate-app/CoCreate-mongodb/commit/5628edf111e46901583fd0ac9fcd5c27687f4204))
|
|
7
|
+
|
|
8
|
+
## [1.17.5](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.4...v1.17.5) (2024-02-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* $storage,$database, etc. if does not exist set as empty array ([a7d1ae4](https://github.com/CoCreate-app/CoCreate-mongodb/commit/a7d1ae4a277ad2f136963b4e78b6c7ba3826c3ba))
|
|
14
|
+
|
|
1
15
|
## [1.17.4](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.3...v1.17.4) (2024-02-13)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -520,6 +520,8 @@ function createUpdate(update, options, data, isGlobal) {
|
|
|
520
520
|
options.upsert = data.upsert
|
|
521
521
|
if (data.$upsert)
|
|
522
522
|
options.upsert = data.$upsert
|
|
523
|
+
if (data.$update)
|
|
524
|
+
delete data.$update
|
|
523
525
|
|
|
524
526
|
Object.keys(data).forEach(key => {
|
|
525
527
|
if (isGlobal && !key.startsWith('$') || key === '_id')
|
|
@@ -560,6 +562,8 @@ function createUpdate(update, options, data, isGlobal) {
|
|
|
560
562
|
}
|
|
561
563
|
if (!key.startsWith('$'))
|
|
562
564
|
operator = '$push'
|
|
565
|
+
if (key.endsWith('[]'))
|
|
566
|
+
key = key.replace('[]', '');
|
|
563
567
|
}
|
|
564
568
|
|
|
565
569
|
let operators = ['$rename', '$inc', '$push', '$each', '$splice', '$unset', '$delete', '$slice', '$pop', '$shift', '$addToSet', '$pull', '$currentDate']
|
|
@@ -725,6 +729,12 @@ function createData(data, array, type, dataTransferedIn, dataTransferedOut) {
|
|
|
725
729
|
for (let i = 0; i < array.length; i++) {
|
|
726
730
|
const matchIndex = data[type].findIndex((item) => item[key] === array[i][key]);
|
|
727
731
|
if (matchIndex !== -1) {
|
|
732
|
+
if (!data[type][matchIndex].$storage)
|
|
733
|
+
data[type][matchIndex].$storage = []
|
|
734
|
+
if (!data[type][matchIndex].$database)
|
|
735
|
+
data[type][matchIndex].$database = []
|
|
736
|
+
if (!data[type][matchIndex].$array)
|
|
737
|
+
data[type][matchIndex].$array = []
|
|
728
738
|
data[type][matchIndex].$storage.push(array[i].$storage)
|
|
729
739
|
delete array[i].$storage
|
|
730
740
|
data[type][matchIndex].$database.push(array[i].$database)
|