@cocreate/mongodb 1.18.0 → 1.18.2

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.18.2](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.1...v1.18.2) (2024-06-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update dependencies ([4fcde07](https://github.com/CoCreate-app/CoCreate-mongodb/commit/4fcde07dcecb5386cde6f0f35020ccad3c9259b3))
7
+
8
+ ## [1.18.1](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.0...v1.18.1) (2024-06-22)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * handling of $storage, $database, and $array refrence ([788c27f](https://github.com/CoCreate-app/CoCreate-mongodb/commit/788c27f4bf1ab8f37aabeb0e7d18d7378385cc07))
14
+
1
15
  # [1.18.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.6...v1.18.0) (2024-04-28)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.18.0",
3
+ "version": "1.18.2",
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.30.0",
48
+ "@cocreate/utils": "^1.34.0",
49
49
  "mongodb": "^4.12.1"
50
50
  }
51
51
  }
package/src/index.js CHANGED
@@ -764,18 +764,19 @@ function createData(data, array, type, dataTransferedIn, dataTransferedOut) {
764
764
  for (let i = 0; i < array.length; i++) {
765
765
  const matchIndex = data[type].findIndex((item) => item[key] === array[i][key]);
766
766
  if (matchIndex !== -1) {
767
- if (!data[type][matchIndex].$storage)
768
- data[type][matchIndex].$storage = []
769
- if (!data[type][matchIndex].$database)
770
- data[type][matchIndex].$database = []
771
- if (!data[type][matchIndex].$array)
772
- data[type][matchIndex].$array = []
773
- data[type][matchIndex].$storage.push(array[i].$storage)
774
- delete array[i].$storage
775
- data[type][matchIndex].$database.push(array[i].$database)
776
- delete array[i].$database
777
- data[type][matchIndex].$array.push(array[i].$array)
778
- delete array[i].$array
767
+ for (let $type of ['$storage', '$database', '$array']) {
768
+ if (!data[type][matchIndex][$type])
769
+ data[type][matchIndex][$type] = []
770
+ if (!Array.isArray(data[type][matchIndex][$type])) {
771
+ data[type][matchIndex][$type] = [data[type][matchIndex][$type]]
772
+ if (!data[type][matchIndex][$type].includes(array[i][$type])) {
773
+ data[type][matchIndex][$type].push(array[i][$type])
774
+ }
775
+ } else {
776
+ data[type][matchIndex][$type].push(array[i][$type])
777
+ }
778
+ delete array[i][$type]
779
+ }
779
780
 
780
781
  // TODO: compare dates and merge and and updates to keep all synced and up to date
781
782
  data[type][matchIndex] = { ...data[type][matchIndex], ...array[i] };