c2-mongoose 2.1.367 → 2.1.369
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/dist/flow/searcher/v3/item/LookupArrayFlowItem.d.ts +1 -1
- package/dist/flow/searcher/v3/item/LookupArrayFlowItem.js +3 -2
- package/dist/flow/searcher/v3/item/PopulateFlowItem.js +1 -1
- package/package.json +1 -1
- package/src/flow/searcher/v3/item/LookupArrayFlowItem.ts +4 -3
- package/src/flow/searcher/v3/item/PopulateFlowItem.ts +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
declare class LookupArrayFlowItem {
|
|
3
|
-
execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>):
|
|
3
|
+
execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>): any[];
|
|
4
4
|
}
|
|
5
5
|
declare const _default: LookupArrayFlowItem;
|
|
6
6
|
export default _default;
|
|
@@ -67,14 +67,15 @@ var LookupArrayFlowItem = /** @class */ (function () {
|
|
|
67
67
|
populateClauseLookup.push({
|
|
68
68
|
$replaceRoot: {
|
|
69
69
|
newRoot: {
|
|
70
|
-
$mergeObjects: ["$doc", (_b = {}, _b["".concat(previousPath)] =
|
|
70
|
+
$mergeObjects: ["$doc", (_b = {}, _b["".concat(previousPath)] = "$".concat(previousPath), _b)]
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
|
-
|
|
74
|
+
return __spreadArray([], populateClauseLookup, true);
|
|
75
75
|
}
|
|
76
76
|
catch (error) {
|
|
77
77
|
console.error(error.message);
|
|
78
|
+
return [];
|
|
78
79
|
}
|
|
79
80
|
};
|
|
80
81
|
return LookupArrayFlowItem;
|
|
@@ -29,7 +29,7 @@ var PopulateFlowItem = /** @class */ (function () {
|
|
|
29
29
|
return;
|
|
30
30
|
var typeFirst = fieldDefinition.instance;
|
|
31
31
|
if (typeFirst === 'Array') {
|
|
32
|
-
LookupArrayFlowItem_1.default.execute(first, rest, populateClauses, modelRoot);
|
|
32
|
+
populateClauses = __spreadArray(__spreadArray([], populateClauses, true), LookupArrayFlowItem_1.default.execute(first, rest, populateClauses, modelRoot), true);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
while ((typeFirst === 'Array' || typeFirst === 'Embedded') && (rest === null || rest === void 0 ? void 0 : rest.length)) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import mongoose from "mongoose";
|
|
|
2
2
|
import GetFieldDefinitionFlowItem from "./GetFieldDefinitionFlowItem";
|
|
3
3
|
|
|
4
4
|
class LookupArrayFlowItem {
|
|
5
|
-
execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>) {
|
|
5
|
+
execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>): any[] {
|
|
6
6
|
|
|
7
7
|
const populateClauseLookup = []
|
|
8
8
|
|
|
@@ -62,14 +62,15 @@ class LookupArrayFlowItem {
|
|
|
62
62
|
populateClauseLookup.push({
|
|
63
63
|
$replaceRoot: {
|
|
64
64
|
newRoot: {
|
|
65
|
-
$mergeObjects: ["$doc", { [`${previousPath}`]:
|
|
65
|
+
$mergeObjects: ["$doc", { [`${previousPath}`]: `$${previousPath}` }]
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
return [...populateClauseLookup]
|
|
71
71
|
} catch (error: any) {
|
|
72
72
|
console.error(error.message)
|
|
73
|
+
return []
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import GetFieldDefinitionFlowItem from "./GetFieldDefinitionFlowItem"
|
|
2
|
+
import GetFieldDefinitionFlowItem from "./GetFieldDefinitionFlowItem";
|
|
3
3
|
import LookupArrayFlowItem from "./LookupArrayFlowItem";
|
|
4
4
|
|
|
5
5
|
class PopulateFlowItem {
|
|
6
6
|
execute(populates: string = "", modelRoot: mongoose.Model<any>): any[] {
|
|
7
7
|
const populatesFields = populates.split(',').map((field: string) => field.trim()).filter((field: string) => field.length > 0);
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
let populateClauses: any[] = []
|
|
10
10
|
populatesFields?.forEach((populateField: string) => {
|
|
11
11
|
let [first, ...rest] = populateField.split('.')
|
|
@@ -18,14 +18,14 @@ class PopulateFlowItem {
|
|
|
18
18
|
let typeFirst = fieldDefinition.instance
|
|
19
19
|
|
|
20
20
|
if (typeFirst === 'Array') {
|
|
21
|
-
LookupArrayFlowItem.execute(first, rest, populateClauses, modelRoot)
|
|
21
|
+
populateClauses = [...populateClauses, ...LookupArrayFlowItem.execute(first, rest, populateClauses, modelRoot)]
|
|
22
22
|
return
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
while ((typeFirst === 'Array' || typeFirst === 'Embedded') && rest?.length) {
|
|
26
26
|
first = [first, rest[0]].join(".")
|
|
27
27
|
rest.splice(0, 1)
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
fieldDefinition = GetFieldDefinitionFlowItem.execute(modelRoot, first);
|
|
30
30
|
|
|
31
31
|
if (!fieldDefinition) return;
|