@cocreate/mongodb 1.17.2 → 1.17.4

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.17.4](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.3...v1.17.4) (2024-02-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added console.log to temporarily log data[type] that are not arrays ([7fc7e1a](https://github.com/CoCreate-app/CoCreate-mongodb/commit/7fc7e1a4b4e4477b462c48be187fe3b6d416721d))
7
+
8
+ ## [1.17.3](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.2...v1.17.3) (2024-02-05)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Removed https://cdn.cocreate.app/latest/CoCreate.min.css ([8988124](https://github.com/CoCreate-app/CoCreate-mongodb/commit/89881240e2053d6b36bb7950ab3705bea7d1e69f))
14
+
1
15
  ## [1.17.2](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.1...v1.17.2) (2024-01-30)
2
16
 
3
17
 
package/docs/index.html CHANGED
@@ -19,10 +19,6 @@
19
19
  <meta name="robots" content="index,follow" />
20
20
 
21
21
  <!-- CoCreate CSS CDN -->
22
- <link
23
- rel="stylesheet"
24
- href="https://cdn.cocreate.app/latest/CoCreate.min.css"
25
- type="text/css" />
26
22
  </head>
27
23
 
28
24
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.17.2",
3
+ "version": "1.17.4",
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",
package/src/index.js CHANGED
@@ -717,20 +717,26 @@ function createData(data, array, type, dataTransferedIn, dataTransferedOut) {
717
717
  let key = '_id'
718
718
  if (type !== 'object')
719
719
  key = 'name'
720
- for (let i = 0; i < array.length; i++) {
721
- const matchIndex = data[type].findIndex((item) => item[key] === array[i][key]);
722
- if (matchIndex !== -1) {
723
- data[type][matchIndex].$storage.push(array[i].$storage)
724
- delete array[i].$storage
725
- data[type][matchIndex].$database.push(array[i].$database)
726
- delete array[i].$database
727
- data[type][matchIndex].$array.push(array[i].$array)
728
- delete array[i].$array
729
-
730
- // TODO: compare dates and merge and and updates to keep all synced and up to date
731
- data[type][matchIndex] = { ...data[type][matchIndex], ...array[i] };
732
- } else
733
- data[type].push(array[i])
720
+
721
+ // TODO: handle case where data[type] is not an array
722
+ if (!Array.isArray(data[type]))
723
+ console.log('data[type] is not an array', type)
724
+ else {
725
+ for (let i = 0; i < array.length; i++) {
726
+ const matchIndex = data[type].findIndex((item) => item[key] === array[i][key]);
727
+ if (matchIndex !== -1) {
728
+ data[type][matchIndex].$storage.push(array[i].$storage)
729
+ delete array[i].$storage
730
+ data[type][matchIndex].$database.push(array[i].$database)
731
+ delete array[i].$database
732
+ data[type][matchIndex].$array.push(array[i].$array)
733
+ delete array[i].$array
734
+
735
+ // TODO: compare dates and merge and and updates to keep all synced and up to date
736
+ data[type][matchIndex] = { ...data[type][matchIndex], ...array[i] };
737
+ } else
738
+ data[type].push(array[i])
739
+ }
734
740
  }
735
741
 
736
742
  return data