@cocreate/mongodb 1.18.6 → 1.18.7

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.18.7](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.6...v1.18.7) (2024-07-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * remove new keyword from ObjectId ([8198e98](https://github.com/CoCreate-app/CoCreate-mongodb/commit/8198e98a7b297607f0a4b171256c7166b9675836))
7
+
1
8
  ## [1.18.6](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.18.5...v1.18.6) (2024-07-03)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/mongodb",
3
- "version": "1.18.6",
3
+ "version": "1.18.7",
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
@@ -338,7 +338,7 @@ function object(method, data) {
338
338
  if (data[type][i]._id || method === 'create') {
339
339
  if (method !== 'create') {
340
340
  try {
341
- query._id = new ObjectId(data[type][i]._id);
341
+ query._id = ObjectId(data[type][i]._id);
342
342
  } catch (error) {
343
343
  if (method === 'update' && options.upsert) {
344
344
  data[type][i]._id = ObjectId()
@@ -369,7 +369,8 @@ function object(method, data) {
369
369
  // documents.push({ ...data[type][i], ...reference })
370
370
  } else if (method === 'read') {
371
371
  result = await arrayObj.findOne(query, projection);
372
- result._id = result._id.toString()
372
+ if (result)
373
+ result._id = result._id.toString()
373
374
 
374
375
  if (data[type][i].$storage && data[type][i].modified && data[type][i].modified.on) {
375
376
  if (!result) {
@@ -381,8 +382,12 @@ function object(method, data) {
381
382
  result = await arrayObj.updateOne(query, update, options);
382
383
  } else
383
384
  data[type][i] = { ...data[type][i], ...result }
384
- } else
385
+ } else if (result)
385
386
  data[type][i] = { ...data[type][i], ...result }
387
+ else {
388
+ data[type].splice(i, 1);
389
+ continue;
390
+ }
386
391
  } else if (method === 'update') {
387
392
  result = await arrayObj.updateOne(query, update, options);
388
393