c2-mongoose 2.1.53 → 2.1.55
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
|
@@ -71,7 +71,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
71
71
|
* @deprecated
|
|
72
72
|
* @returns
|
|
73
73
|
*/
|
|
74
|
-
this.searchPageableOld = function (model) { return __awaiter(_this, void 0, void 0, function () {
|
|
74
|
+
this.searchPageableOld = function (model, session) { return __awaiter(_this, void 0, void 0, function () {
|
|
75
75
|
var sort, items;
|
|
76
76
|
return __generator(this, function (_a) {
|
|
77
77
|
switch (_a.label) {
|
|
@@ -83,6 +83,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
83
83
|
.skip((this.page - 1) * this.limit)
|
|
84
84
|
.limit(this.limit)
|
|
85
85
|
.sort(sort)
|
|
86
|
+
.session(session)
|
|
86
87
|
.collation({
|
|
87
88
|
locale: Environment_1.dbCollation || "pt"
|
|
88
89
|
})];
|
|
@@ -176,6 +177,9 @@ var SearchFlow = /** @class */ (function () {
|
|
|
176
177
|
]).session(options === null || options === void 0 ? void 0 : options.session)];
|
|
177
178
|
case 1:
|
|
178
179
|
result = _b.sent();
|
|
180
|
+
return [4 /*yield*/, model.populate(result[0].items, __assign(__assign({}, this.populate), { select: this.select }))];
|
|
181
|
+
case 2:
|
|
182
|
+
_b.sent();
|
|
179
183
|
return [2 /*return*/, {
|
|
180
184
|
items: result[0].items,
|
|
181
185
|
paging: ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.paging[0]) || { total: 0, page: 1, limit: this.limit }
|
|
@@ -193,15 +197,15 @@ var SearchFlow = /** @class */ (function () {
|
|
|
193
197
|
if (!(options === null || options === void 0 ? void 0 : options.pipelines)) return [3 /*break*/, 2];
|
|
194
198
|
return [4 /*yield*/, this.searchPageable(model, options)];
|
|
195
199
|
case 1: return [2 /*return*/, _a.sent()];
|
|
196
|
-
case 2: return [4 /*yield*/, this.searchPageableOld(model)];
|
|
200
|
+
case 2: return [4 /*yield*/, this.searchPageableOld(model, options === null || options === void 0 ? void 0 : options.session)];
|
|
197
201
|
case 3: return [2 /*return*/, _a.sent()];
|
|
198
|
-
case 4: return [4 /*yield*/, this.searchNoPageable(model)];
|
|
202
|
+
case 4: return [4 /*yield*/, this.searchNoPageable(model, options === null || options === void 0 ? void 0 : options.session)];
|
|
199
203
|
case 5: return [2 /*return*/, _a.sent()];
|
|
200
204
|
}
|
|
201
205
|
});
|
|
202
206
|
});
|
|
203
207
|
};
|
|
204
|
-
SearchFlow.prototype.searchNoPageable = function (model) {
|
|
208
|
+
SearchFlow.prototype.searchNoPageable = function (model, session) {
|
|
205
209
|
return __awaiter(this, void 0, void 0, function () {
|
|
206
210
|
var sort, items;
|
|
207
211
|
return __generator(this, function (_a) {
|
|
@@ -212,6 +216,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
212
216
|
.find(this.filters, this.select)
|
|
213
217
|
.populate(this.populate)
|
|
214
218
|
.sort(sort)
|
|
219
|
+
.session(session)
|
|
215
220
|
.collation({
|
|
216
221
|
locale: Environment_1.dbCollation || "pt"
|
|
217
222
|
})];
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -103,6 +103,9 @@ abstract class SearchFlow {
|
|
|
103
103
|
}
|
|
104
104
|
]
|
|
105
105
|
).session(options?.session as ClientSession)
|
|
106
|
+
|
|
107
|
+
await model.populate(result[0].items, { ...this.populate, select: this.select })
|
|
108
|
+
|
|
106
109
|
return {
|
|
107
110
|
items: result[0].items,
|
|
108
111
|
paging: result[0]?.paging[0] || { total: 0, page: 1, limit: this.limit }
|
|
@@ -114,10 +117,10 @@ abstract class SearchFlow {
|
|
|
114
117
|
if (options?.pipelines) {
|
|
115
118
|
return await this.searchPageable(model, options)
|
|
116
119
|
}
|
|
117
|
-
return await this.searchPageableOld(model)
|
|
120
|
+
return await this.searchPageableOld(model, options?.session)
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
return await this.searchNoPageable(model)
|
|
123
|
+
return await this.searchNoPageable(model, options?.session)
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
/**
|
|
@@ -126,7 +129,7 @@ abstract class SearchFlow {
|
|
|
126
129
|
* @deprecated
|
|
127
130
|
* @returns
|
|
128
131
|
*/
|
|
129
|
-
private searchPageableOld = async (model: mongoose.Model<any
|
|
132
|
+
private searchPageableOld = async (model: mongoose.Model<any>, session?: ClientSession): Promise<SearchResponse<any>> => {
|
|
130
133
|
const sort = this.buildOrdenation()
|
|
131
134
|
var items = await model
|
|
132
135
|
.find(this.filters, this.select)
|
|
@@ -134,6 +137,7 @@ abstract class SearchFlow {
|
|
|
134
137
|
.skip((this.page - 1) * this.limit)
|
|
135
138
|
.limit(this.limit)
|
|
136
139
|
.sort(sort)
|
|
140
|
+
.session(session!)
|
|
137
141
|
.collation({
|
|
138
142
|
locale: dbCollation || "pt"
|
|
139
143
|
}) as []
|
|
@@ -141,12 +145,13 @@ abstract class SearchFlow {
|
|
|
141
145
|
return this.result(model, items)
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
private async searchNoPageable(model: mongoose.Model<any
|
|
148
|
+
private async searchNoPageable(model: mongoose.Model<any>, session?: ClientSession): Promise<SearchResponse<any>> {
|
|
145
149
|
const sort = this.buildOrdenation()
|
|
146
150
|
var items = await model
|
|
147
151
|
.find(this.filters, this.select)
|
|
148
152
|
.populate(this.populate)
|
|
149
153
|
.sort(sort)
|
|
154
|
+
.session(session!)
|
|
150
155
|
.collation({
|
|
151
156
|
locale: dbCollation || "pt"
|
|
152
157
|
}) as []
|