c2-mongoose 2.1.250 → 2.1.252
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/SearcherFlow.js +26 -21
- package/package.json +1 -1
- package/src/flow/SearcherFlow.ts +33 -28
- package/src/types/SearchResponse.d.ts +1 -0
|
@@ -105,10 +105,6 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
105
105
|
}
|
|
106
106
|
stagesItems.push({ $sort: this.buildOrdenation() });
|
|
107
107
|
}
|
|
108
|
-
if (this.pageable === true) {
|
|
109
|
-
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 });
|
|
110
|
-
stagesItems.push({ $limit: this.limit });
|
|
111
|
-
}
|
|
112
108
|
stagesPaging = [];
|
|
113
109
|
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
114
110
|
stagesPaging.push.apply(stagesPaging, options.pipelines);
|
|
@@ -116,23 +112,32 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
116
112
|
if ((0, Utils_1.isNotEmpty)(options.unions)) {
|
|
117
113
|
stagesPaging.push.apply(stagesPaging, options.unions);
|
|
118
114
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
115
|
+
if ((0, Utils_1.isEmpty)(options.paging)) {
|
|
116
|
+
stagesPaging.push({ $match: this.filters });
|
|
117
|
+
stagesPaging.push({ $count: "total" });
|
|
118
|
+
stagesPaging.push({
|
|
119
|
+
$addFields: {
|
|
120
|
+
page: this.pageable === true ? this.page : 1,
|
|
121
|
+
limit: this.pageable === true ? this.limit : '$total',
|
|
122
|
+
totalPages: this.pageable === true ? {
|
|
123
|
+
$cond: {
|
|
124
|
+
if: { $eq: ['$total', 0] },
|
|
125
|
+
then: 0,
|
|
126
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
127
|
+
}
|
|
128
|
+
} : 1,
|
|
129
|
+
startIndex: this.pageable === true ? { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] } : 1,
|
|
130
|
+
endIndex: this.pageable === true ? { $multiply: [this.page, this.limit] } : '$total'
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
stagesPaging = __spreadArray(__spreadArray([], stagesPaging, true), options.paging, true);
|
|
136
|
+
}
|
|
137
|
+
if (this.pageable === true) {
|
|
138
|
+
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 });
|
|
139
|
+
stagesItems.push({ $limit: this.limit });
|
|
140
|
+
}
|
|
136
141
|
stagesMetadata = [];
|
|
137
142
|
if ((0, Utils_1.isNotEmpty)(options.metadata)) {
|
|
138
143
|
stagesMetadata.push.apply(stagesMetadata, options.metadata);
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -44,7 +44,7 @@ class SearcherFlow<D> {
|
|
|
44
44
|
async search(options: SearchOptions): Promise<SearchResponse<D>> {
|
|
45
45
|
|
|
46
46
|
let stagesItems: any[] = []
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
if (isNotEmpty(options.pipelines)) {
|
|
49
49
|
stagesItems.push(...options.pipelines)
|
|
50
50
|
}
|
|
@@ -52,21 +52,16 @@ class SearcherFlow<D> {
|
|
|
52
52
|
stagesItems.push(...options.unions)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (isEmpty(options.pipelines)){
|
|
55
|
+
if (isEmpty(options.pipelines)) {
|
|
56
56
|
stagesItems.push({ $match: this.filters })
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
if (isNotEmpty(this.select)) {
|
|
59
59
|
stagesItems.push({ $project: BuildSelectSingleFlowItem.build(this.model, this.select) })
|
|
60
60
|
}
|
|
61
61
|
stagesItems.push({ $sort: this.buildOrdenation() })
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 })
|
|
66
|
-
stagesItems.push({ $limit: this.limit })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
|
|
64
|
+
///
|
|
70
65
|
let stagesPaging: any[] = []
|
|
71
66
|
if (isNotEmpty(options.pipelines)) {
|
|
72
67
|
stagesPaging.push(...options.pipelines)
|
|
@@ -75,23 +70,33 @@ class SearcherFlow<D> {
|
|
|
75
70
|
stagesPaging.push(...options.unions)
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
$
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
73
|
+
|
|
74
|
+
if (isEmpty(options.paging)) {
|
|
75
|
+
stagesPaging.push({ $match: this.filters })
|
|
76
|
+
stagesPaging.push({ $count: "total" })
|
|
77
|
+
stagesPaging.push({
|
|
78
|
+
$addFields: {
|
|
79
|
+
page: this.pageable === true ? this.page : 1,
|
|
80
|
+
limit: this.pageable === true ? this.limit : '$total',
|
|
81
|
+
totalPages: this.pageable === true ? {
|
|
82
|
+
$cond: {
|
|
83
|
+
if: { $eq: ['$total', 0] },
|
|
84
|
+
then: 0,
|
|
85
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
86
|
+
}
|
|
87
|
+
} : 1,
|
|
88
|
+
startIndex: this.pageable === true ? { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] } : 1,
|
|
89
|
+
endIndex: this.pageable === true ? { $multiply: [this.page, this.limit] } : '$total'
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
} else {
|
|
93
|
+
stagesPaging = [...stagesPaging, ...options.paging]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this.pageable === true) {
|
|
97
|
+
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 })
|
|
98
|
+
stagesItems.push({ $limit: this.limit })
|
|
99
|
+
}
|
|
95
100
|
|
|
96
101
|
let stagesMetadata: any[] = []
|
|
97
102
|
if (isNotEmpty(options.metadata)) {
|
|
@@ -154,7 +159,7 @@ class SearcherFlow<D> {
|
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
161
|
|
|
157
|
-
extractFieldsOfType(schema: Schema, typing = 'String', parent = ''): string[]{
|
|
162
|
+
extractFieldsOfType(schema: Schema, typing = 'String', parent = ''): string[] {
|
|
158
163
|
let fieldsTyped: string[] = []
|
|
159
164
|
Object.keys(schema.paths).forEach((field: string) => {
|
|
160
165
|
if (schema.paths[field].instance === typing) {
|