c2-mongoose 2.1.433 → 2.1.435
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.
|
@@ -48,10 +48,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
49
|
};
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
var
|
|
51
|
+
var MatchV3FlowItem_1 = __importDefault(require("./item/MatchV3FlowItem"));
|
|
52
52
|
var PopulateV3FlowItem_1 = __importDefault(require("./item/PopulateV3FlowItem"));
|
|
53
|
+
var OneToManyV3FlowItem_1 = __importDefault(require("./item/OneToManyV3FlowItem"));
|
|
53
54
|
var ProjectV3FlowItem_1 = __importDefault(require("./item/ProjectV3FlowItem"));
|
|
54
|
-
var MatchV3FlowItem_1 = __importDefault(require("./item/MatchV3FlowItem"));
|
|
55
55
|
var GetOneByFilterV3Flow = /** @class */ (function () {
|
|
56
56
|
function GetOneByFilterV3Flow() {
|
|
57
57
|
}
|
|
@@ -59,7 +59,7 @@ var GetOneByFilterV3Flow = /** @class */ (function () {
|
|
|
59
59
|
var _a, _b;
|
|
60
60
|
if (oneToMany === void 0) { oneToMany = []; }
|
|
61
61
|
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var pipeline, result;
|
|
62
|
+
var pipeline, mainFilters, result;
|
|
63
63
|
return __generator(this, function (_c) {
|
|
64
64
|
switch (_c.label) {
|
|
65
65
|
case 0:
|
|
@@ -69,11 +69,13 @@ var GetOneByFilterV3Flow = /** @class */ (function () {
|
|
|
69
69
|
}
|
|
70
70
|
pipeline = __spreadArray(__spreadArray([], pipeline, true), PopulateV3FlowItem_1.default.execute(params.populate, model), true);
|
|
71
71
|
pipeline = __spreadArray(__spreadArray([], pipeline, true), OneToManyV3FlowItem_1.default.execute(oneToMany, params.populate), true);
|
|
72
|
+
pipeline = __spreadArray(__spreadArray([], pipeline, true), MatchV3FlowItem_1.default.execute(params, model), true);
|
|
72
73
|
pipeline = __spreadArray(__spreadArray([], pipeline, true), ProjectV3FlowItem_1.default.execute(params.select), true);
|
|
73
74
|
if ((_b = params.posSteps) === null || _b === void 0 ? void 0 : _b.length) {
|
|
74
75
|
pipeline = __spreadArray(__spreadArray([], pipeline, true), params.posSteps, true);
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
+
mainFilters = params.mainFilter ? __spreadArray([], MatchV3FlowItem_1.default.execute(params.mainFilter, model), true) : [];
|
|
78
|
+
return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], mainFilters, true), pipeline, true), {
|
|
77
79
|
collation: {
|
|
78
80
|
locale: "pt",
|
|
79
81
|
numericOrdering: true
|
|
@@ -59,12 +59,12 @@ var SearcherV3Flow = /** @class */ (function () {
|
|
|
59
59
|
function SearcherV3Flow() {
|
|
60
60
|
}
|
|
61
61
|
SearcherV3Flow.prototype.exec = function (params, model, oneToMany) {
|
|
62
|
-
var _a, _b, _c, _d, _e;
|
|
62
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
63
63
|
if (oneToMany === void 0) { oneToMany = []; }
|
|
64
64
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var facet, pipelineFacetPaging, pipelineFacetItems, _i,
|
|
66
|
-
return __generator(this, function (
|
|
67
|
-
switch (
|
|
65
|
+
var facet, pipelineFacetPaging, pipelineFacetItems, _i, _h, metaObj, _j, _k, _l, key, value, mainFilters, result, ret, _m, _o, _p, key, value;
|
|
66
|
+
return __generator(this, function (_q) {
|
|
67
|
+
switch (_q.label) {
|
|
68
68
|
case 0:
|
|
69
69
|
params.page = Number((_a = params.page) !== null && _a !== void 0 ? _a : 1);
|
|
70
70
|
params.limit = Number((_b = params.limit) !== null && _b !== void 0 ? _b : 50);
|
|
@@ -88,15 +88,15 @@ var SearcherV3Flow = /** @class */ (function () {
|
|
|
88
88
|
{ $skip: (params.page - 1) * (params.limit) },
|
|
89
89
|
{ $limit: params.limit }
|
|
90
90
|
], false);
|
|
91
|
-
pipelineFacetPaging = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], GroupV3FlowItem_1.default.execute(params.groupBy, params.sumFields, params.groupDetailed, model), true), PopulateV3FlowItem_1.default.execute(params.populate, model), true), OneToManyV3FlowItem_1.default.execute(oneToMany, params.populate), true), MatchV3FlowItem_1.default.execute(params, model), true), BuildPaginationDataV3FlowItem_1.default.execute(params.page, params.limit), true);
|
|
91
|
+
pipelineFacetPaging = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], ((_e = params.preSteps) === null || _e === void 0 ? void 0 : _e.length) ? params.preSteps : [], true), GroupV3FlowItem_1.default.execute(params.groupBy, params.sumFields, params.groupDetailed, model), true), PopulateV3FlowItem_1.default.execute(params.populate, model), true), OneToManyV3FlowItem_1.default.execute(oneToMany, params.populate), true), MatchV3FlowItem_1.default.execute(params, model), true), ((_f = params.posSteps) === null || _f === void 0 ? void 0 : _f.length) ? params.posSteps : [], true), BuildPaginationDataV3FlowItem_1.default.execute(params.page, params.limit), true);
|
|
92
92
|
facet.paging = pipelineFacetPaging;
|
|
93
93
|
}
|
|
94
94
|
facet.items = pipelineFacetItems;
|
|
95
95
|
if (params.metadata) {
|
|
96
|
-
for (_i = 0,
|
|
97
|
-
metaObj =
|
|
98
|
-
for (
|
|
99
|
-
|
|
96
|
+
for (_i = 0, _h = params.metadata; _i < _h.length; _i++) {
|
|
97
|
+
metaObj = _h[_i];
|
|
98
|
+
for (_j = 0, _k = Object.entries(metaObj); _j < _k.length; _j++) {
|
|
99
|
+
_l = _k[_j], key = _l[0], value = _l[1];
|
|
100
100
|
facet[key] = value;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -113,11 +113,11 @@ var SearcherV3Flow = /** @class */ (function () {
|
|
|
113
113
|
}
|
|
114
114
|
}).read('secondaryPreferred')];
|
|
115
115
|
case 1:
|
|
116
|
-
result =
|
|
116
|
+
result = _q.sent();
|
|
117
117
|
ret = {};
|
|
118
118
|
ret.items = result[0].items;
|
|
119
119
|
if (params.pageable !== false) {
|
|
120
|
-
ret.paging = (
|
|
120
|
+
ret.paging = (_g = result[0].paging[0]) !== null && _g !== void 0 ? _g : {
|
|
121
121
|
page: 1,
|
|
122
122
|
limit: 50,
|
|
123
123
|
total: 0,
|
|
@@ -126,8 +126,8 @@ var SearcherV3Flow = /** @class */ (function () {
|
|
|
126
126
|
endIndex: 0
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
-
for (
|
|
130
|
-
|
|
129
|
+
for (_m = 0, _o = Object.entries(result[0]); _m < _o.length; _m++) {
|
|
130
|
+
_p = _o[_m], key = _p[0], value = _p[1];
|
|
131
131
|
if (key.startsWith("metadata-")) {
|
|
132
132
|
ret[key] = result[0][key];
|
|
133
133
|
}
|
package/package.json
CHANGED
|
@@ -4,6 +4,9 @@ import PopulateFlowItem from "./item/PopulateV3FlowItem"
|
|
|
4
4
|
import ProjectFlowItem from "./item/ProjectV3FlowItem"
|
|
5
5
|
import MatchV3FlowItem from "./item/MatchV3FlowItem"
|
|
6
6
|
import { IParams } from "./SearcherV3Flow"
|
|
7
|
+
import PopulateV3FlowItem from "./item/PopulateV3FlowItem"
|
|
8
|
+
import OneToManyV3FlowItem from "./item/OneToManyV3FlowItem"
|
|
9
|
+
import ProjectV3FlowItem from "./item/ProjectV3FlowItem"
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
|
|
@@ -15,16 +18,19 @@ class GetOneByFilterV3Flow {
|
|
|
15
18
|
if (params.preSteps?.length) {
|
|
16
19
|
pipeline = [...pipeline, ...params.preSteps]
|
|
17
20
|
}
|
|
18
|
-
pipeline = [...pipeline, ...
|
|
19
|
-
pipeline = [...pipeline, ...
|
|
20
|
-
pipeline = [...pipeline, ...
|
|
21
|
+
pipeline = [...pipeline, ...PopulateV3FlowItem.execute(params.populate, model)]
|
|
22
|
+
pipeline = [...pipeline, ...OneToManyV3FlowItem.execute(oneToMany, params.populate)]
|
|
23
|
+
pipeline = [...pipeline, ...MatchV3FlowItem.execute(params, model)]
|
|
24
|
+
pipeline = [...pipeline, ...ProjectV3FlowItem.execute(params.select)]
|
|
21
25
|
|
|
22
26
|
if (params.posSteps?.length) {
|
|
23
27
|
pipeline = [...pipeline, ...params.posSteps]
|
|
24
28
|
}
|
|
25
29
|
|
|
30
|
+
const mainFilters = params.mainFilter ? [...MatchV3FlowItem.execute(params.mainFilter, model)] : []
|
|
31
|
+
|
|
26
32
|
let result = await model.aggregate([
|
|
27
|
-
...
|
|
33
|
+
...mainFilters,
|
|
28
34
|
...pipeline
|
|
29
35
|
], {
|
|
30
36
|
collation: {
|
|
@@ -49,10 +49,15 @@ class SearcherV3Flow {
|
|
|
49
49
|
]
|
|
50
50
|
|
|
51
51
|
pipelineFacetPaging = [
|
|
52
|
+
...params.preSteps?.length ? params.preSteps : [],
|
|
53
|
+
|
|
52
54
|
...GroupV3FlowItem.execute(params.groupBy, params.sumFields, params.groupDetailed, model),
|
|
53
55
|
...PopulateV3FlowItem.execute(params.populate, model),
|
|
54
56
|
...OneToManyV3FlowItem.execute(oneToMany, params.populate),
|
|
55
57
|
...MatchV3FlowItem.execute(params, model),
|
|
58
|
+
|
|
59
|
+
...params.posSteps?.length ? params.posSteps : [],
|
|
60
|
+
|
|
56
61
|
...BuildPaginationDataV3FlowItem.execute(params.page, params.limit),
|
|
57
62
|
]
|
|
58
63
|
facet.paging = pipelineFacetPaging
|