c2-mongoose 2.1.84 → 2.1.86
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
CHANGED
|
@@ -195,13 +195,14 @@ var SearchFlow = /** @class */ (function () {
|
|
|
195
195
|
return __generator(this, function (_c) {
|
|
196
196
|
switch (_c.label) {
|
|
197
197
|
case 0:
|
|
198
|
-
stagesItems = __spreadArray([
|
|
198
|
+
stagesItems = __spreadArray(__spreadArray([
|
|
199
199
|
{ $match: this.filters },
|
|
200
|
+
this.projection ? { $project: this.projection } : { $addFields: {} }
|
|
201
|
+
], options.pipelines, true), [
|
|
200
202
|
{ $sort: this.sort },
|
|
201
203
|
{ $skip: ((this.page - 1) * this.limit) || 0 },
|
|
202
204
|
{ $limit: this.limit },
|
|
203
|
-
|
|
204
|
-
], options.pipelines, true);
|
|
205
|
+
], false);
|
|
205
206
|
return [4 /*yield*/, model.aggregate([
|
|
206
207
|
{
|
|
207
208
|
$facet: {
|
|
@@ -410,6 +411,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
410
411
|
});
|
|
411
412
|
};
|
|
412
413
|
SearchFlow.prototype.buildDefaultFilters = function (objectSearch) {
|
|
414
|
+
var _this = this;
|
|
413
415
|
var filters = { $and: [] };
|
|
414
416
|
Object.entries(objectSearch.model).forEach(function (_a) {
|
|
415
417
|
var key = _a[0], value = _a[1];
|
|
@@ -448,7 +450,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
448
450
|
}
|
|
449
451
|
else if (key.endsWith('Like')) {
|
|
450
452
|
var fieldName = key.replace('Like', '');
|
|
451
|
-
condition[fieldName] = { $regex: value, $options: 'i' }
|
|
453
|
+
condition[fieldName] = _this.buildRegex(value); //{ $regex: value as any, $options: 'i' }
|
|
452
454
|
filters.$and.push(condition);
|
|
453
455
|
}
|
|
454
456
|
else {
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -120,11 +120,11 @@ abstract class SearchFlow {
|
|
|
120
120
|
async searchPageable(model: mongoose.Model<any>, options: SearchOptions) {
|
|
121
121
|
let stagesItems = [
|
|
122
122
|
{ $match: this.filters },
|
|
123
|
+
this.projection ? { $project: this.projection } : { $addFields: {} },
|
|
124
|
+
...options.pipelines,
|
|
123
125
|
{ $sort: this.sort },
|
|
124
126
|
{ $skip: ((this.page - 1) * this.limit) || 0 },
|
|
125
127
|
{ $limit: this.limit },
|
|
126
|
-
this.projection ? { $project: this.projection } : { $addFields: {} },
|
|
127
|
-
...options.pipelines
|
|
128
128
|
]
|
|
129
129
|
|
|
130
130
|
const result = await model.aggregate(
|
|
@@ -350,7 +350,7 @@ abstract class SearchFlow {
|
|
|
350
350
|
filters.$and.push(condition)
|
|
351
351
|
} else if (key.endsWith('Like')) {
|
|
352
352
|
var fieldName = key.replace('Like', '')
|
|
353
|
-
condition[fieldName] = { $regex: value as any, $options: 'i' }
|
|
353
|
+
condition[fieldName] = this.buildRegex(value as string) //{ $regex: value as any, $options: 'i' }
|
|
354
354
|
filters.$and.push(condition)
|
|
355
355
|
} else {
|
|
356
356
|
if (!Array.isArray(value)) {
|