@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 +7 -0
- package/package.json +1 -1
- package/src/index.js +8 -3
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
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 =
|
|
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
|
-
|
|
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
|
|