@cocreate/mongodb 1.3.0 → 1.3.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.3.1](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.3.0...v1.3.1) (2023-05-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * $set keys were deletes due to array handeling function unnecessary keys to reduce clutter and improve efficiency. ([979d873](https://github.com/CoCreate-app/CoCreate-mongodb/commit/979d87391bbac72c65123b665f5b088d19fd5594))
7
+
1
8
  # [1.3.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.2.5...v1.3.0) (2023-05-19)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.3.0",
3
+ "version": "1.3.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
@@ -579,17 +579,18 @@ function createUpdate(data, type) {
579
579
  delete update['$set']['_id']
580
580
  Object.keys(update['$set']).forEach(key => {
581
581
 
582
- if (key.includes('[u]'))
582
+ if (key.includes('[u]')) {
583
583
  update['$addToSet'] = { [key.replace('[u]', '')]: update['$set'][key] }
584
- else if (key.includes('[]')) {
584
+ delete update['$set'][key]
585
+ } else if (key.includes('[]')) {
585
586
  if (!Array.isArray(update['$set'][key]))
586
587
  update['$set'][key] = [update['$set'][key]]
587
588
 
588
589
  update['$push'] = {
589
590
  [key.replace('[]', '')]: { $each: update['$set'][key] }
590
591
  }
592
+ delete update['$set'][key]
591
593
  }
592
- delete update['$set'][key]
593
594
  // { $push: { "skills": { $each: ["Sports", "Acting"] } } })
594
595
  // { $addToSet: { "skills": "GST" } }) // adds "GST"to all arrays if not exist
595
596
  projection[key] = 1