@cocreate/mongodb 1.18.4 → 1.18.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.18.6](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.5...v1.18.6) (2024-07-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * handling objectId in queries ([58c92b2](https://github.com/CoCreate-app/CoCreate-mongodb/commit/58c92b259da510e8020ff9211c72ce678905aceb))
7
+
8
+ ## [1.18.5](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.4...v1.18.5) (2024-07-01)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * if startingIndex use as index ([7d5ee2e](https://github.com/CoCreate-app/CoCreate-mongodb/commit/7d5ee2e88d7a47270db0ea7045a87181bd9672e3))
14
+
1
15
  ## [1.18.4](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.3...v1.18.4) (2024-06-23)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.18.4",
3
+ "version": "1.18.6",
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
@@ -412,6 +412,9 @@ function object(method, data) {
412
412
  if (method === 'read')
413
413
  projection = { ...projections, ...projection }
414
414
 
415
+ if (data.$filter && data.$filter.startingIndex >= 0)
416
+ index = data.$filter.startingIndex
417
+
415
418
  dataTransferedOut += getBytes({ query, projection, sort, index, limit })
416
419
 
417
420
  let document = ''
@@ -649,10 +652,16 @@ async function createFilter(data, arrayObj) {
649
652
  if (typeof condition[subKey] === 'object' && condition[subKey] !== null) {
650
653
  newCondition[subKey] = {};
651
654
  for (let subCondition in condition[subKey]) {
652
- newCondition[subKey][subCondition] = convertIfDate(condition[subKey][subCondition]);
655
+ if (subKey == "_id")
656
+ newCondition[subKey][subCondition] = ObjectId(condition[subKey][subCondition])
657
+ else
658
+ newCondition[subKey][subCondition] = convertIfDate(condition[subKey][subCondition]);
653
659
  }
654
660
  } else {
655
- newCondition[subKey] = convertIfDate(condition[subKey]);
661
+ if (subKey == "_id")
662
+ newCondition[subKey] = ObjectId(condition[subKey])
663
+ else
664
+ newCondition[subKey] = convertIfDate(condition[subKey]);
656
665
  }
657
666
  }
658
667
  return newCondition;
@@ -661,11 +670,17 @@ async function createFilter(data, arrayObj) {
661
670
  // Handle general object conditions
662
671
  query[key] = {};
663
672
  for (let condition in data.$filter.query[key]) {
664
- query[key][condition] = convertIfDate(data.$filter.query[key][condition]);
673
+ if (key == "_id")
674
+ query[key][condition] = ObjectId(data.$filter.query[key][condition])
675
+ else
676
+ query[key][condition] = convertIfDate(data.$filter.query[key][condition]);
665
677
  }
666
678
  } else {
667
679
  // Handle direct values
668
- query[key] = convertIfDate(data.$filter.query[key]);
680
+ if (key == "_id")
681
+ query[key] = ObjectId(data.$filter.query[key])
682
+ else
683
+ query[key] = convertIfDate(data.$filter.query[key]);
669
684
  }
670
685
  }
671
686
  }