c2-mongoose 2.1.448 → 2.1.451
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/GroupV3FlowItem.js +2 -10
- package/dist/flow/searcher/v3/item/OneToManyV3FlowItem.d.ts +1 -0
- package/dist/flow/searcher/v3/item/OneToManyV3FlowItem.js +30 -22
- package/package.json +1 -1
- package/src/flow/searcher/v3/item/GroupV3FlowItem.ts +2 -14
- package/src/flow/searcher/v3/item/OneToManyV3FlowItem.ts +36 -23
|
@@ -77,17 +77,9 @@ var GroupV3FlowItem = /** @class */ (function () {
|
|
|
77
77
|
if (detailed && (filters === null || filters === void 0 ? void 0 : filters.docsOrderBy)) {
|
|
78
78
|
var ordenation = (_b = filters.docsOrderBy) === null || _b === void 0 ? void 0 : _b.split(',').map(function (field) { return field === null || field === void 0 ? void 0 : field.trim(); });
|
|
79
79
|
var sortByFields_1 = {};
|
|
80
|
-
ordenation === null || ordenation === void 0 ? void 0 : ordenation.
|
|
81
|
-
sortByFields_1[order
|
|
80
|
+
ordenation === null || ordenation === void 0 ? void 0 : ordenation.forEach(function (order) {
|
|
81
|
+
sortByFields_1[order] = filters.docsOrderSense === 'desc' ? -1 : 1;
|
|
82
82
|
});
|
|
83
|
-
// const groupOrderBy = Array.isArray(filters.groupOrderBy) ? filters.groupOrderBy : [filters.groupOrderBy]
|
|
84
|
-
// const docgroupOrderBy = groupOrderBy.filter((o: string) => typeof o === 'string' && o.startsWith('docs.'))
|
|
85
|
-
// const sortByFields: Record<string, 1 | -1> = {}
|
|
86
|
-
// for (const o of docgroupOrderBy) {
|
|
87
|
-
// sortByFields[o.replace(/^doc\./, '')] = filters.orderSense === 'desc' ? -1 : 1
|
|
88
|
-
// }
|
|
89
|
-
// const remaininggroupOrderBy = ordenation.filter((o: string) => typeof o !== 'string' || !o.startsWith('docs.'))
|
|
90
|
-
// filters.groupOrderBy = remaininggroupOrderBy.length ? remaininggroupOrderBy.join(',') : undefined
|
|
91
83
|
if (Object.keys(sortByFields_1).length > 0) {
|
|
92
84
|
groupsClauses.push({
|
|
93
85
|
$set: {
|
|
@@ -23,32 +23,40 @@ var OneToManyV3FlowItem = /** @class */ (function () {
|
|
|
23
23
|
foreings === null || foreings === void 0 ? void 0 : foreings.forEach(function (foreing) {
|
|
24
24
|
var labeled = (0, lodash_1.camelCase)(foreing.collectionChild);
|
|
25
25
|
var populateClauseLookup = [];
|
|
26
|
+
var pipeline = [];
|
|
26
27
|
if (foreing.match) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let: { localField: '$_id' },
|
|
31
|
-
localField: "_id",
|
|
32
|
-
foreignField: foreing.parentFieldOnChild,
|
|
33
|
-
as: labeled,
|
|
34
|
-
pipeline: [
|
|
35
|
-
{
|
|
36
|
-
$match: foreing.match
|
|
37
|
-
},
|
|
38
|
-
]
|
|
28
|
+
pipeline = __spreadArray(__spreadArray([], pipeline, true), [
|
|
29
|
+
{
|
|
30
|
+
$match: foreing.match
|
|
39
31
|
}
|
|
40
|
-
|
|
32
|
+
], false);
|
|
41
33
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
$
|
|
45
|
-
|
|
46
|
-
localField: "_id",
|
|
47
|
-
foreignField: foreing.parentFieldOnChild,
|
|
48
|
-
as: labeled
|
|
49
|
-
}
|
|
50
|
-
});
|
|
34
|
+
if (foreing.sort) {
|
|
35
|
+
pipeline = __spreadArray(__spreadArray([], pipeline, true), [
|
|
36
|
+
{ $sort: foreing.sort }
|
|
37
|
+
], false);
|
|
51
38
|
}
|
|
39
|
+
// if (foreing.match) {
|
|
40
|
+
populateClauseLookup.push({
|
|
41
|
+
$lookup: {
|
|
42
|
+
from: foreing.collectionChild,
|
|
43
|
+
let: { localField: '$_id' },
|
|
44
|
+
foreignField: foreing.parentFieldOnChild,
|
|
45
|
+
as: labeled,
|
|
46
|
+
pipeline: pipeline
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// }
|
|
50
|
+
// else {
|
|
51
|
+
// populateClauseLookup.push({
|
|
52
|
+
// $lookup: {
|
|
53
|
+
// from: foreing.collectionChild, // The collection where user data is stored
|
|
54
|
+
// localField: "_id",
|
|
55
|
+
// foreignField: foreing.parentFieldOnChild,
|
|
56
|
+
// as: labeled
|
|
57
|
+
// }
|
|
58
|
+
// })
|
|
59
|
+
// }
|
|
52
60
|
collection = __spreadArray(__spreadArray([], collection, true), populateClauseLookup, true);
|
|
53
61
|
var model = global.connectionMongoose.models[Object.keys(global.connectionMongoose.models).find(function (key) { return global.connectionMongoose.models[key].collection.name === foreing.collectionChild; })];
|
|
54
62
|
if (model) {
|
package/package.json
CHANGED
|
@@ -81,25 +81,13 @@ class GroupV3FlowItem {
|
|
|
81
81
|
|
|
82
82
|
if (detailed && filters?.docsOrderBy) {
|
|
83
83
|
|
|
84
|
-
|
|
85
84
|
const ordenation = filters.docsOrderBy?.split(',').map((field: string) => field?.trim())
|
|
86
85
|
|
|
87
86
|
const sortByFields: Record<string, 1 | -1> = {}
|
|
88
|
-
ordenation?.
|
|
89
|
-
sortByFields[order
|
|
87
|
+
ordenation?.forEach((order: string) => {
|
|
88
|
+
sortByFields[order] = filters.docsOrderSense === 'desc' ? -1 : 1
|
|
90
89
|
})
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
// const groupOrderBy = Array.isArray(filters.groupOrderBy) ? filters.groupOrderBy : [filters.groupOrderBy]
|
|
94
|
-
// const docgroupOrderBy = groupOrderBy.filter((o: string) => typeof o === 'string' && o.startsWith('docs.'))
|
|
95
|
-
// const sortByFields: Record<string, 1 | -1> = {}
|
|
96
|
-
// for (const o of docgroupOrderBy) {
|
|
97
|
-
// sortByFields[o.replace(/^doc\./, '')] = filters.orderSense === 'desc' ? -1 : 1
|
|
98
|
-
// }
|
|
99
|
-
|
|
100
|
-
// const remaininggroupOrderBy = ordenation.filter((o: string) => typeof o !== 'string' || !o.startsWith('docs.'))
|
|
101
|
-
// filters.groupOrderBy = remaininggroupOrderBy.length ? remaininggroupOrderBy.join(',') : undefined
|
|
102
|
-
|
|
103
91
|
if (Object.keys(sortByFields).length > 0) {
|
|
104
92
|
groupsClauses.push({
|
|
105
93
|
$set: {
|
|
@@ -4,6 +4,7 @@ export interface IForeingData {
|
|
|
4
4
|
collectionChild: string;
|
|
5
5
|
parentFieldOnChild: string;
|
|
6
6
|
match?: any
|
|
7
|
+
sort?: any
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
class OneToManyV3FlowItem {
|
|
@@ -14,33 +15,45 @@ class OneToManyV3FlowItem {
|
|
|
14
15
|
const labeled = camelCase(foreing.collectionChild)
|
|
15
16
|
const populateClauseLookup: any[] = []
|
|
16
17
|
|
|
18
|
+
let pipeline: any[] = []
|
|
19
|
+
|
|
17
20
|
if (foreing.match) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
localField: "_id",
|
|
23
|
-
foreignField: foreing.parentFieldOnChild,
|
|
24
|
-
as: labeled,
|
|
25
|
-
pipeline: [
|
|
26
|
-
{
|
|
27
|
-
$match:
|
|
28
|
-
foreing.match
|
|
29
|
-
},
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
} else {
|
|
34
|
-
populateClauseLookup.push({
|
|
35
|
-
$lookup: {
|
|
36
|
-
from: foreing.collectionChild, // The collection where user data is stored
|
|
37
|
-
localField: "_id",
|
|
38
|
-
foreignField: foreing.parentFieldOnChild,
|
|
39
|
-
as: labeled
|
|
21
|
+
pipeline = [
|
|
22
|
+
...pipeline,
|
|
23
|
+
{
|
|
24
|
+
$match: foreing.match
|
|
40
25
|
}
|
|
41
|
-
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
if (foreing.sort) {
|
|
29
|
+
pipeline = [
|
|
30
|
+
...pipeline,
|
|
31
|
+
{ $sort: foreing.sort }
|
|
32
|
+
]
|
|
42
33
|
}
|
|
43
34
|
|
|
35
|
+
// if (foreing.match) {
|
|
36
|
+
populateClauseLookup.push({
|
|
37
|
+
$lookup: {
|
|
38
|
+
from: foreing.collectionChild, // The collection where user data is stored
|
|
39
|
+
let: { localField: '$_id' },
|
|
40
|
+
foreignField: foreing.parentFieldOnChild,
|
|
41
|
+
as: labeled,
|
|
42
|
+
pipeline: pipeline
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
// }
|
|
46
|
+
// else {
|
|
47
|
+
// populateClauseLookup.push({
|
|
48
|
+
// $lookup: {
|
|
49
|
+
// from: foreing.collectionChild, // The collection where user data is stored
|
|
50
|
+
// localField: "_id",
|
|
51
|
+
// foreignField: foreing.parentFieldOnChild,
|
|
52
|
+
// as: labeled
|
|
53
|
+
// }
|
|
54
|
+
// })
|
|
55
|
+
// }
|
|
56
|
+
|
|
44
57
|
collection = [...collection, ...populateClauseLookup]
|
|
45
58
|
|
|
46
59
|
let model = (global as any).connectionMongoose.models[
|