c2-mongoose 2.1.50 → 2.1.52
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.d.ts +1 -1
- package/dist/flow/SearchFlow.js +13 -13
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +9 -9
|
@@ -15,7 +15,7 @@ declare abstract class SearchFlow {
|
|
|
15
15
|
buildPopulate(): any;
|
|
16
16
|
buildPath(target: string, nested?: string): any;
|
|
17
17
|
buildOrdenation(): any;
|
|
18
|
-
|
|
18
|
+
buildRegex(searchText: string): RegExp;
|
|
19
19
|
searchPageable(model: mongoose.Model<any>, pipeline: any): Promise<{
|
|
20
20
|
items: any;
|
|
21
21
|
paging: any;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -135,21 +135,21 @@ var SearchFlow = /** @class */ (function () {
|
|
|
135
135
|
this.sort = order;
|
|
136
136
|
return order;
|
|
137
137
|
};
|
|
138
|
-
SearchFlow.prototype.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
.replace(
|
|
142
|
-
.replace(
|
|
143
|
-
.replace(
|
|
144
|
-
.replace(/[
|
|
145
|
-
|
|
146
|
-
.replace(/[ç|Ç|c|C]/g, '[c,C,ç,Ç]');
|
|
138
|
+
SearchFlow.prototype.buildRegex = function (searchText) {
|
|
139
|
+
var regexExpression = searchText
|
|
140
|
+
.replace(/^"/, '^').replace(/"$/, '$') //Replace aspas duplas para busca exata
|
|
141
|
+
.replace(/^%22/, '^').replace(/%22$/, '$') //Replace aspas duplas para busca exata
|
|
142
|
+
.replace(/%20/, ' ') //Replace espaço em branco para nao quebrar o proximo replace
|
|
143
|
+
.replace(/%/g, '.*?') //Replace % para o padrão regex (% é muito utilizado como o .*? e é mais simples para o usuario digitar)
|
|
144
|
+
.replace(/[ç|c|C|Ç]/g, '[c,ç]');
|
|
145
|
+
return new RegExp("".concat(regexExpression), 'i');
|
|
147
146
|
};
|
|
148
147
|
SearchFlow.prototype.searchPageable = function (model, pipeline) {
|
|
148
|
+
var _a;
|
|
149
149
|
return __awaiter(this, void 0, void 0, function () {
|
|
150
150
|
var stagesItems, result;
|
|
151
|
-
return __generator(this, function (
|
|
152
|
-
switch (
|
|
151
|
+
return __generator(this, function (_b) {
|
|
152
|
+
switch (_b.label) {
|
|
153
153
|
case 0:
|
|
154
154
|
stagesItems = __spreadArray([
|
|
155
155
|
{ $match: this.filters },
|
|
@@ -175,10 +175,10 @@ var SearchFlow = /** @class */ (function () {
|
|
|
175
175
|
}
|
|
176
176
|
])];
|
|
177
177
|
case 1:
|
|
178
|
-
result =
|
|
178
|
+
result = _b.sent();
|
|
179
179
|
return [2 /*return*/, {
|
|
180
180
|
items: result[0].items,
|
|
181
|
-
paging: result[0].paging[0]
|
|
181
|
+
paging: ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.paging[0]) || { total: 0, page: 1, limit: this.limit }
|
|
182
182
|
}];
|
|
183
183
|
}
|
|
184
184
|
});
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -64,14 +64,14 @@ abstract class SearchFlow {
|
|
|
64
64
|
return order
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.replace(/
|
|
70
|
-
.replace(
|
|
71
|
-
.replace(
|
|
72
|
-
.replace(
|
|
73
|
-
.replace(/[
|
|
74
|
-
|
|
67
|
+
buildRegex(searchText: string): RegExp {
|
|
68
|
+
let regexExpression = searchText
|
|
69
|
+
.replace(/^"/, '^').replace(/"$/, '$') //Replace aspas duplas para busca exata
|
|
70
|
+
.replace(/^%22/, '^').replace(/%22$/, '$') //Replace aspas duplas para busca exata
|
|
71
|
+
.replace(/%20/, ' ') //Replace espaço em branco para nao quebrar o proximo replace
|
|
72
|
+
.replace(/%/g, '.*?') //Replace % para o padrão regex (% é muito utilizado como o .*? e é mais simples para o usuario digitar)
|
|
73
|
+
.replace(/[ç|c|C|Ç]/g, '[c,ç]')
|
|
74
|
+
return new RegExp(`${regexExpression}`, 'i');
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
async searchPageable(model: mongoose.Model<any>, pipeline: any) {
|
|
@@ -105,7 +105,7 @@ abstract class SearchFlow {
|
|
|
105
105
|
)
|
|
106
106
|
return {
|
|
107
107
|
items: result[0].items,
|
|
108
|
-
paging: result[0]
|
|
108
|
+
paging: result[0]?.paging[0] || { total: 0, page: 1, limit: this.limit }
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|