c2-mongoose 2.1.41 → 2.1.43
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.
|
@@ -16,8 +16,8 @@ declare abstract class SearchFlow {
|
|
|
16
16
|
buildPath(target: string, nested?: string): any;
|
|
17
17
|
buildOrdenation(): any;
|
|
18
18
|
diacriticSensitiveRegex(string?: string): string;
|
|
19
|
-
searchPageable(model: mongoose.Model<any>,
|
|
20
|
-
search(model: mongoose.Model<any>,
|
|
19
|
+
searchPageable(model: mongoose.Model<any>, pipeline: any): Promise<any>;
|
|
20
|
+
search(model: mongoose.Model<any>, pipeline: any): Promise<SearchResponse<any>>;
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @param model
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -46,15 +46,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
51
|
};
|
|
@@ -145,11 +136,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
145
136
|
.replace(/[u|ü|ú|ù|U|Ú|Ü|Ù]/g, '[u,ü,ú,ù,U,Ú,Ü,Ù]')
|
|
146
137
|
.replace(/[ç|Ç|c|C]/g, '[c,C,ç,Ç]');
|
|
147
138
|
};
|
|
148
|
-
SearchFlow.prototype.searchPageable = function (model) {
|
|
149
|
-
var pipeline = [];
|
|
150
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
151
|
-
pipeline[_i - 1] = arguments[_i];
|
|
152
|
-
}
|
|
139
|
+
SearchFlow.prototype.searchPageable = function (model, pipeline) {
|
|
153
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
154
141
|
var result;
|
|
155
142
|
return __generator(this, function (_a) {
|
|
@@ -157,12 +144,13 @@ var SearchFlow = /** @class */ (function () {
|
|
|
157
144
|
case 0: return [4 /*yield*/, model.aggregate([
|
|
158
145
|
{
|
|
159
146
|
$facet: {
|
|
160
|
-
items:
|
|
147
|
+
items: [
|
|
161
148
|
{ $match: this.filters },
|
|
162
149
|
{ $sort: this.sort },
|
|
163
150
|
{ $skip: (this.page - 1) * this.limit },
|
|
164
|
-
{ $limit: this.limit }
|
|
165
|
-
|
|
151
|
+
{ $limit: this.limit },
|
|
152
|
+
pipeline
|
|
153
|
+
],
|
|
166
154
|
paging: [
|
|
167
155
|
{ $match: this.filters },
|
|
168
156
|
{ $count: "total" },
|
|
@@ -183,11 +171,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
183
171
|
});
|
|
184
172
|
});
|
|
185
173
|
};
|
|
186
|
-
SearchFlow.prototype.search = function (model) {
|
|
187
|
-
var pipeline = [];
|
|
188
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
189
|
-
pipeline[_i - 1] = arguments[_i];
|
|
190
|
-
}
|
|
174
|
+
SearchFlow.prototype.search = function (model, pipeline) {
|
|
191
175
|
return __awaiter(this, void 0, void 0, function () {
|
|
192
176
|
return __generator(this, function (_a) {
|
|
193
177
|
switch (_a.label) {
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -74,7 +74,7 @@ abstract class SearchFlow {
|
|
|
74
74
|
.replace(/[ç|Ç|c|C]/g, '[c,C,ç,Ç]')
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
async searchPageable(model: mongoose.Model<any>,
|
|
77
|
+
async searchPageable(model: mongoose.Model<any>, pipeline: any) {
|
|
78
78
|
const result = await model.aggregate(
|
|
79
79
|
[
|
|
80
80
|
{
|
|
@@ -84,7 +84,7 @@ abstract class SearchFlow {
|
|
|
84
84
|
{ $sort: this.sort },
|
|
85
85
|
{ $skip: (this.page - 1) * this.limit },
|
|
86
86
|
{ $limit: this.limit },
|
|
87
|
-
|
|
87
|
+
pipeline
|
|
88
88
|
],
|
|
89
89
|
paging: [
|
|
90
90
|
{ $match: this.filters },
|
|
@@ -104,7 +104,7 @@ abstract class SearchFlow {
|
|
|
104
104
|
return result[0]
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
public async search(model: mongoose.Model<any>,
|
|
107
|
+
public async search(model: mongoose.Model<any>, pipeline: any): Promise<SearchResponse<any>> {
|
|
108
108
|
if (this.pageable == true) {
|
|
109
109
|
if (pipeline) {
|
|
110
110
|
return await this.searchPageable(model, pipeline)
|