c2-mongoose 2.1.151 → 2.1.153
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/SearchFlow.js +15 -15
- package/dist/flow/item/GetStagePaginationFlowItem.d.ts +7 -0
- package/dist/flow/item/GetStagePaginationFlowItem.js +20 -0
- package/dist/index.d.ts +2 -1
- package/dist/model/Facet.d.ts +13 -0
- package/dist/model/Facet.js +2 -0
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +10 -14
- package/src/flow/item/GetStagePaginationFlowItem.ts +23 -0
- package/src/index.ts +2 -1
- package/src/model/Facet.ts +15 -0
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -97,23 +97,23 @@ var SearchFlow = /** @class */ (function () {
|
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
var populates = [];
|
|
100
|
+
var _loop_1 = function () {
|
|
101
|
+
var _b = property.split('.'), first = _b[0], rest = _b.slice(1);
|
|
102
|
+
var nested = rest.join('.');
|
|
103
|
+
var populate = this_1.buildPath(first, nested);
|
|
104
|
+
if (Array.isArray(this_1.select)) {
|
|
105
|
+
var selects = this_1.select.filter(function (sel) { return sel.startsWith("".concat(first, ".")); });
|
|
106
|
+
var select = selects.map(function (sel) { return sel.split(".")[1]; }).join(" ");
|
|
107
|
+
if ((0, Utils_1.isNotEmpty)(select)) {
|
|
108
|
+
populate.select = select;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
populates.push(populate);
|
|
112
|
+
};
|
|
113
|
+
var this_1 = this;
|
|
100
114
|
for (var _i = 0, _a = this.populate; _i < _a.length; _i++) {
|
|
101
115
|
var property = _a[_i];
|
|
102
|
-
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
populates.push(property);
|
|
106
|
-
// let [first, ...rest] = property.split('.')
|
|
107
|
-
// let nested = rest.join('.')
|
|
108
|
-
// let populate = this.buildPath(first, nested)
|
|
109
|
-
// if (Array.isArray(this.select)) {
|
|
110
|
-
// let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
|
|
111
|
-
// let select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
|
|
112
|
-
// if (isNotEmpty(select)) {
|
|
113
|
-
// populate.select = select
|
|
114
|
-
// }
|
|
115
|
-
// }
|
|
116
|
-
// populates.push(populate)
|
|
116
|
+
_loop_1();
|
|
117
117
|
}
|
|
118
118
|
return populates;
|
|
119
119
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var GetStagePaginationFlowItem = /** @class */ (function () {
|
|
4
|
+
function GetStagePaginationFlowItem() {
|
|
5
|
+
}
|
|
6
|
+
GetStagePaginationFlowItem.prototype.get = function (facet, searcher) {
|
|
7
|
+
var facetAfter = facet;
|
|
8
|
+
if (searcher.pageable === true) {
|
|
9
|
+
facetAfter.items.push({ $skip: ((searcher.page - 1) * searcher.limit) || 0 });
|
|
10
|
+
facetAfter.items.push({ $limit: searcher.limit });
|
|
11
|
+
facetAfter.paging = [
|
|
12
|
+
{ $count: "total" },
|
|
13
|
+
{ $addFields: { page: searcher.page || 1, limit: searcher.limit } }
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
return facetAfter;
|
|
17
|
+
};
|
|
18
|
+
return GetStagePaginationFlowItem;
|
|
19
|
+
}());
|
|
20
|
+
exports.default = new GetStagePaginationFlowItem;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import CrudFlow from "./flow/CrudFlow";
|
|
|
3
3
|
import SearchFlow from "./flow/SearchFlow";
|
|
4
4
|
import BuildPipelineToCountJoinFlowItem from "./flow/item/BuildPipelineToCountJoinFlowItem";
|
|
5
5
|
import BuildPipelineToJoinFlowItem from "./flow/item/BuildPipelineToJoinFlowItem";
|
|
6
|
+
import { IFacet } from "./model/Facet";
|
|
6
7
|
import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger";
|
|
7
8
|
import { Options } from "./types/Options";
|
|
8
9
|
import { Pagination, SearchResponse } from "./types/SearchResponse";
|
|
9
10
|
import { initialize } from "./utils/Utils";
|
|
10
|
-
export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem };
|
|
11
|
+
export { C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet };
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -74,21 +74,17 @@ abstract class SearchFlow {
|
|
|
74
74
|
|
|
75
75
|
var populates = [] as any
|
|
76
76
|
for (var property of this.populate) {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
let [first, ...rest] = property.split('.')
|
|
78
|
+
let nested = rest.join('.')
|
|
79
|
+
let populate = this.buildPath(first, nested)
|
|
80
|
+
if (Array.isArray(this.select)) {
|
|
81
|
+
let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
|
|
82
|
+
let select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
|
|
83
|
+
if (isNotEmpty(select)) {
|
|
84
|
+
populate.select = select
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
|
-
populates.push(
|
|
81
|
-
// let [first, ...rest] = property.split('.')
|
|
82
|
-
// let nested = rest.join('.')
|
|
83
|
-
// let populate = this.buildPath(first, nested)
|
|
84
|
-
// if (Array.isArray(this.select)) {
|
|
85
|
-
// let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
|
|
86
|
-
// let select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
|
|
87
|
-
// if (isNotEmpty(select)) {
|
|
88
|
-
// populate.select = select
|
|
89
|
-
// }
|
|
90
|
-
// }
|
|
91
|
-
// populates.push(populate)
|
|
87
|
+
populates.push(populate)
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
return populates
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IFacet } from "../../model/Facet"
|
|
2
|
+
import SearchFlow from "../SearchFlow"
|
|
3
|
+
|
|
4
|
+
class GetStagePaginationFlowItem {
|
|
5
|
+
|
|
6
|
+
get(facet: IFacet, searcher: SearchFlow): IFacet {
|
|
7
|
+
let facetAfter: IFacet = facet
|
|
8
|
+
|
|
9
|
+
if (searcher.pageable === true) {
|
|
10
|
+
facetAfter.items.push({ $skip: ((searcher.page - 1) * searcher.limit) || 0 })
|
|
11
|
+
facetAfter.items.push({ $limit: searcher.limit })
|
|
12
|
+
|
|
13
|
+
facetAfter.paging = [
|
|
14
|
+
{ $count: "total" },
|
|
15
|
+
{ $addFields: { page: searcher.page || 1, limit: searcher.limit } }
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return facetAfter
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default new GetStagePaginationFlowItem
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import CrudFlow from "./flow/CrudFlow"
|
|
|
3
3
|
import SearchFlow from "./flow/SearchFlow"
|
|
4
4
|
import BuildPipelineToCountJoinFlowItem from "./flow/item/BuildPipelineToCountJoinFlowItem"
|
|
5
5
|
import BuildPipelineToJoinFlowItem from "./flow/item/BuildPipelineToJoinFlowItem"
|
|
6
|
+
import { IFacet } from "./model/Facet"
|
|
6
7
|
import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Logger"
|
|
7
8
|
import { Options } from "./types/Options"
|
|
8
9
|
import { Pagination, SearchResponse } from "./types/SearchResponse"
|
|
@@ -12,6 +13,6 @@ import { initialize } from "./utils/Utils"
|
|
|
12
13
|
|
|
13
14
|
export {
|
|
14
15
|
C2Flow, CrudFlow, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize,
|
|
15
|
-
BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem
|
|
16
|
+
BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, IFacet
|
|
16
17
|
}
|
|
17
18
|
|