@cocreate/mongodb 1.16.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 CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  # [1.16.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.15.0...v1.16.0) (2024-01-08)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.16.0",
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",
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 === '$push')
585
- updates[key] = [data[originalKey]]
584
+ if (!operator)
585
+ operator = "$set"
586
+ else {
587
+ if (operator === '$push')
588
+ updates[key] = [data[originalKey]]
586
589
 
587
- let insert = { $each: updates[key] }
588
- insert.$postion = index
589
- updates[key] = insert
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]