@cocreate/mongodb 1.3.2 → 1.4.0
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 +14 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.4.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.3.2...v1.4.0) (2023-05-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Refactor index.js document function to return updated documents when returnDocument is set to false. ([6dba55b](https://github.com/CoCreate-app/CoCreate-mongodb/commit/6dba55b93237d7e411ddacb09be7242f103edc7f))
|
|
7
|
+
|
|
1
8
|
## [1.3.2](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.3.1...v1.3.2) (2023-05-20)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -397,6 +397,20 @@ function document(action, data) {
|
|
|
397
397
|
doc.database = database
|
|
398
398
|
doc.collection = collection
|
|
399
399
|
doc._id = doc._id.toString()
|
|
400
|
+
|
|
401
|
+
if (data.returnDocument == false) {
|
|
402
|
+
let tempDoc = {};
|
|
403
|
+
let docs = new Map(data[type].map((obj) => [obj._id, obj]));
|
|
404
|
+
let doc1 = docs.get(doc._id)
|
|
405
|
+
if (doc1) {
|
|
406
|
+
tempDoc._id = tempDoc
|
|
407
|
+
for (let key of Object.keys(doc1)) {
|
|
408
|
+
tempDoc[key] = doc[key]
|
|
409
|
+
}
|
|
410
|
+
doc = tempDoc
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
400
414
|
documents.push(doc)
|
|
401
415
|
}
|
|
402
416
|
}
|
|
@@ -404,18 +418,6 @@ function document(action, data) {
|
|
|
404
418
|
if (index && limit) {
|
|
405
419
|
documents = documents.slice(index, limit)
|
|
406
420
|
}
|
|
407
|
-
|
|
408
|
-
if (data.returnDocument == false) {
|
|
409
|
-
|
|
410
|
-
for (let item of data['data']) {
|
|
411
|
-
let resp = {};
|
|
412
|
-
resp['_id'] = tmp['_id']
|
|
413
|
-
data[type].forEach((f) => resp[f] = item[f])
|
|
414
|
-
documents.push(resp);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
data['data'] = documents
|
|
418
|
-
}
|
|
419
421
|
}
|
|
420
422
|
|
|
421
423
|
collectionsLength -= 1
|