c2-mongoose 2.1.206 → 2.1.208
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.
|
@@ -20,7 +20,7 @@ declare abstract class SearchFlow {
|
|
|
20
20
|
onlyMetadata: boolean;
|
|
21
21
|
projection: {
|
|
22
22
|
[key: string]: number;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
constructor(params: any);
|
|
25
25
|
buildProjections(): any;
|
|
26
26
|
buildProjectionNested(projectCurrent: any, field: string, include: boolean): any;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -213,7 +213,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
213
213
|
if (!(_a < _b.length)) return [3 /*break*/, 5];
|
|
214
214
|
populate = _b[_a];
|
|
215
215
|
_c = result[0];
|
|
216
|
-
return [4 /*yield*/, model.populate(result[0].items, populate)];
|
|
216
|
+
return [4 /*yield*/, model.populate(result[0].items, { populate: populate, select: this.projection[populate.path] })];
|
|
217
217
|
case 3:
|
|
218
218
|
_c.items = _d.sent();
|
|
219
219
|
_d.label = 4;
|
|
@@ -307,7 +307,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
307
307
|
if (!(_a < _b.length)) return [3 /*break*/, 5];
|
|
308
308
|
populate = _b[_a];
|
|
309
309
|
_c = result[0];
|
|
310
|
-
return [4 /*yield*/, model.populate(result[0].items, populate)];
|
|
310
|
+
return [4 /*yield*/, model.populate(result[0].items, { populate: populate, select: this.projection[populate.path] })];
|
|
311
311
|
case 3:
|
|
312
312
|
_c.items = _d.sent();
|
|
313
313
|
_d.label = 4;
|
|
@@ -9,9 +9,9 @@ var BuildLogFlowItem = /** @class */ (function () {
|
|
|
9
9
|
function BuildLogFlowItem() {
|
|
10
10
|
}
|
|
11
11
|
BuildLogFlowItem.prototype.build = function (options, dataAfter, operation, repository) {
|
|
12
|
-
var _a;
|
|
12
|
+
var _a, _b;
|
|
13
13
|
return {
|
|
14
|
-
user: new mongoose_1.Types.ObjectId((_a = options.user) !== null && _a !== void 0 ? _a : express_http_context_1.default.get("user")._id),
|
|
14
|
+
user: new mongoose_1.Types.ObjectId((_a = options.user) !== null && _a !== void 0 ? _a : (_b = express_http_context_1.default.get("user")) === null || _b === void 0 ? void 0 : _b._id),
|
|
15
15
|
owner: new mongoose_1.Types.ObjectId(options.owner),
|
|
16
16
|
data: dataAfter,
|
|
17
17
|
collectionName: repository.collection.name,
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// import moment from "moment"
|
|
2
|
-
import mongoose, { ClientSession, Types } from "mongoose"
|
|
2
|
+
import mongoose, { ClientSession, PopulateOption, PopulateOptions, Types } from "mongoose"
|
|
3
3
|
import { SearchOptions, SearchResponse } from "../types/SearchResponse"
|
|
4
4
|
import { isEmpty, isNotEmpty } from "../utils/Utils"
|
|
5
5
|
import moment from "moment-timezone"
|
|
@@ -22,7 +22,7 @@ abstract class SearchFlow {
|
|
|
22
22
|
sort: any
|
|
23
23
|
pageable: boolean
|
|
24
24
|
onlyMetadata: boolean
|
|
25
|
-
projection: { [key: string]: number }
|
|
25
|
+
projection: { [key: string]: number }
|
|
26
26
|
|
|
27
27
|
constructor(params: any) {
|
|
28
28
|
// Incluir as propriedades adicionais de 'params' como propriedades da classe
|
|
@@ -203,7 +203,7 @@ abstract class SearchFlow {
|
|
|
203
203
|
|
|
204
204
|
if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
|
|
205
205
|
for (var populate of this.populate) {
|
|
206
|
-
result[0].items = await model.populate(result[0].items, populate)
|
|
206
|
+
result[0].items = await model.populate(result[0].items, { populate, select: this.projection[populate.path] } as PopulateOptions )
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -293,7 +293,7 @@ abstract class SearchFlow {
|
|
|
293
293
|
|
|
294
294
|
if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
|
|
295
295
|
for (var populate of this.populate) {
|
|
296
|
-
result[0].items = await model.populate(result[0].items, populate)
|
|
296
|
+
result[0].items = await model.populate(result[0].items, { populate, select: this.projection[populate.path] } as PopulateOptions )
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
|
@@ -6,7 +6,7 @@ import mongoose, { Types } from "mongoose"
|
|
|
6
6
|
class BuildLogFlowItem {
|
|
7
7
|
build(options: Partial<Options>, dataAfter: any, operation: TypeOfOperation, repository: mongoose.Model<any>): Partial<ILogger> {
|
|
8
8
|
return {
|
|
9
|
-
user: new Types.ObjectId(options.user ?? httpContext.get("user")
|
|
9
|
+
user: new Types.ObjectId(options.user ?? httpContext.get("user")?._id),
|
|
10
10
|
owner: new Types.ObjectId(options.owner),
|
|
11
11
|
data: dataAfter,
|
|
12
12
|
collectionName: repository.collection.name,
|