@cocreate/mongodb 1.15.0 → 1.16.1
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 +15 -0
- package/package.json +2 -2
- package/src/index.js +25 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.16.1](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.16.0...v1.16.1) (2024-01-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handling of array item update ([a189784](https://github.com/CoCreate-app/CoCreate-mongodb/commit/a1897845606460defe3d3d628e73b18d3abf6f32))
|
|
7
|
+
|
|
8
|
+
# [1.16.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.15.0...v1.16.0) (2024-01-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* bumped CoCreate dependencies to their latest versions ([6cbffba](https://github.com/CoCreate-app/CoCreate-mongodb/commit/6cbffba8c2a1582e770d213ec509a6f35be4b9b6))
|
|
14
|
+
* support $elemMatch operator ([520cda3](https://github.com/CoCreate-app/CoCreate-mongodb/commit/520cda3080816d487d0bc2e02c58996392f33a3b))
|
|
15
|
+
|
|
1
16
|
# [1.15.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.14.0...v1.15.0) (2023-11-25)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/mongodb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "A simple mongodb component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mongodb",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"main": "./src/index.js",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@cocreate/utils": "^1.
|
|
48
|
+
"@cocreate/utils": "^1.30.0",
|
|
49
49
|
"mongodb": "^4.12.1"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/index.js
CHANGED
|
@@ -581,12 +581,20 @@ function createUpdate(update, options, data, isGlobal) {
|
|
|
581
581
|
} else if (operator === '$push' || operator === '$each' || typeof index === 'number') {
|
|
582
582
|
updates[key] = data[originalKey]
|
|
583
583
|
if (typeof index === 'number' && index >= 0) {
|
|
584
|
-
if (operator
|
|
585
|
-
|
|
584
|
+
if (!operator)
|
|
585
|
+
operator = "$set"
|
|
586
|
+
else {
|
|
587
|
+
if (operator === '$push')
|
|
588
|
+
updates[key] = [data[originalKey]]
|
|
586
589
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
+
|
|
591
|
+
let insert = { $each: updates[key] }
|
|
592
|
+
insert.$postion = index
|
|
593
|
+
if (index >= 0)
|
|
594
|
+
updates[arrayKey] = insert
|
|
595
|
+
else
|
|
596
|
+
updates[key] = insert
|
|
597
|
+
}
|
|
590
598
|
}
|
|
591
599
|
} else if (operator === '$inc') {
|
|
592
600
|
updates[key] = data[originalKey]
|
|
@@ -709,6 +717,15 @@ function createQuery(queries) {
|
|
|
709
717
|
else
|
|
710
718
|
query[key] = { $nin: item.value }
|
|
711
719
|
break;
|
|
720
|
+
case '$elemMatch':
|
|
721
|
+
query[key] = {
|
|
722
|
+
"$elemMatch": {
|
|
723
|
+
name: {
|
|
724
|
+
$in: item.value
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
712
729
|
case '$or':
|
|
713
730
|
if (!query[item.operator])
|
|
714
731
|
query[item.operator] = [{ [key]: item.value }];
|
|
@@ -728,6 +745,9 @@ function createQuery(queries) {
|
|
|
728
745
|
console.log('geowithin error');
|
|
729
746
|
}
|
|
730
747
|
break;
|
|
748
|
+
case 'dotNotation':
|
|
749
|
+
// TODO: handle CoCreate query using dotNotation, objects and utils.dotNotionToObject to perform deep merge
|
|
750
|
+
break;
|
|
731
751
|
}
|
|
732
752
|
}
|
|
733
753
|
|