@cocreate/mongodb 1.21.0 → 1.21.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 +7 -0
- package/package.json +1 -1
- package/src/index.js +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.21.1](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.21.0...v1.21.1) (2024-12-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* projection handeling ([ee8a878](https://github.com/CoCreate-app/CoCreate-mongodb/commit/ee8a87856bd2032242b2e0dd5f05b995ee519f23))
|
|
7
|
+
|
|
1
8
|
# [1.21.0](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.20.0...v1.21.0) (2024-11-26)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -374,6 +374,9 @@ function object(method, data) {
|
|
|
374
374
|
update = {},
|
|
375
375
|
options = {};
|
|
376
376
|
|
|
377
|
+
if (data.$filter && data.$filter.key)
|
|
378
|
+
projection = data.$filter.key
|
|
379
|
+
|
|
377
380
|
if (method === "update")
|
|
378
381
|
createUpdate(update, options, data, true);
|
|
379
382
|
|
|
@@ -422,7 +425,7 @@ function object(method, data) {
|
|
|
422
425
|
by: data.user_id || data.clientId
|
|
423
426
|
};
|
|
424
427
|
} else if (method === "read") {
|
|
425
|
-
projection = createProjection(data[type][i]);
|
|
428
|
+
// projection = createProjection(projection, data[type][i]);
|
|
426
429
|
} else if (method === "update") {
|
|
427
430
|
if (!data[type][i].modified)
|
|
428
431
|
data[type][i].modified = {
|
|
@@ -492,7 +495,7 @@ function object(method, data) {
|
|
|
492
495
|
} else if (method === "read") {
|
|
493
496
|
result = await arrayObj.findOne(
|
|
494
497
|
query,
|
|
495
|
-
projection
|
|
498
|
+
{projection}
|
|
496
499
|
);
|
|
497
500
|
if (result)
|
|
498
501
|
result._id = result._id.toString();
|
|
@@ -608,14 +611,14 @@ function object(method, data) {
|
|
|
608
611
|
document = "";
|
|
609
612
|
if (Object.keys(sort).length > 0)
|
|
610
613
|
cursor = arrayObj
|
|
611
|
-
.find(query, projection)
|
|
614
|
+
.find(query, {projection})
|
|
612
615
|
.sort(sort)
|
|
613
616
|
.skip(index)
|
|
614
617
|
.limit(limit)
|
|
615
618
|
.allowDiskUse(true);
|
|
616
619
|
else
|
|
617
620
|
cursor = arrayObj
|
|
618
|
-
.find(query, projection)
|
|
621
|
+
.find(query, {projection})
|
|
619
622
|
.sort(sort)
|
|
620
623
|
.skip(index)
|
|
621
624
|
.limit(limit);
|
|
@@ -1072,11 +1075,9 @@ function parseRegExp(regExpString) {
|
|
|
1072
1075
|
};
|
|
1073
1076
|
}
|
|
1074
1077
|
|
|
1075
|
-
function createProjection(data) {
|
|
1076
|
-
let projection = {};
|
|
1077
|
-
|
|
1078
|
+
function createProjection(projection, data) {
|
|
1078
1079
|
Object.keys(data).forEach((key) => {
|
|
1079
|
-
if (!["_id", "organization_id"].includes(key) && !key.startsWith("$"))
|
|
1080
|
+
if (!["_id", "organization_id", "isFIlter"].includes(key) && !key.startsWith("$"))
|
|
1080
1081
|
projection[key.replace(/\[(\d+)\]/g, ".$1")] = 1;
|
|
1081
1082
|
});
|
|
1082
1083
|
|