c2-mongoose 2.1.210 → 2.1.212
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
|
@@ -214,7 +214,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
214
214
|
if (!(_a < _b.length)) return [3 /*break*/, 5];
|
|
215
215
|
populate = _b[_a];
|
|
216
216
|
_c = result[0];
|
|
217
|
-
return [4 /*yield*/, model.populate(result[0].items, { populate
|
|
217
|
+
return [4 /*yield*/, model.populate(result[0].items, __assign(__assign({}, populate), { select: this.projection ? this.projection[populate.path] : undefined }))];
|
|
218
218
|
case 3:
|
|
219
219
|
_c.items = _d.sent();
|
|
220
220
|
_d.label = 4;
|
|
@@ -308,7 +308,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
308
308
|
if (!(_a < _b.length)) return [3 /*break*/, 5];
|
|
309
309
|
populate = _b[_a];
|
|
310
310
|
_c = result[0];
|
|
311
|
-
return [4 /*yield*/, model.populate(result[0].items, { populate
|
|
311
|
+
return [4 /*yield*/, model.populate(result[0].items, __assign(__assign({}, populate), { select: this.projection ? this.projection[populate.path] : undefined }))];
|
|
312
312
|
case 3:
|
|
313
313
|
_c.items = _d.sent();
|
|
314
314
|
_d.label = 4;
|
|
@@ -27,11 +27,10 @@ var BuildSelectSingleFlowItem = /** @class */ (function () {
|
|
|
27
27
|
};
|
|
28
28
|
BuildSelectSingleFlowItem.prototype.buildProjectionNested = function (model, projectCurrent, field, include) {
|
|
29
29
|
var _a = field.split('.'), first = _a[0], rest = _a.slice(1);
|
|
30
|
-
if ((0, Utils_1.
|
|
30
|
+
if ((0, Utils_1.isNotEmpty)(first) && (0, Utils_1.isNotEmpty)(rest)) {
|
|
31
31
|
var campoInfo = model.schema.path(first);
|
|
32
32
|
// Verifique se o tipo do campo é mongoose.Types.ObjectId
|
|
33
33
|
if (campoInfo.instance === "ObjectID") {
|
|
34
|
-
console.log('O campo é um Types.ObjectId');
|
|
35
34
|
return undefined;
|
|
36
35
|
}
|
|
37
36
|
}
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -204,7 +204,7 @@ abstract class SearchFlow {
|
|
|
204
204
|
|
|
205
205
|
if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
|
|
206
206
|
for (var populate of this.populate) {
|
|
207
|
-
result[0].items = await model.populate(result[0].items, { populate, select: this.projection[populate.path] } as PopulateOptions)
|
|
207
|
+
result[0].items = await model.populate(result[0].items, { ...populate, select: this.projection ? this.projection[populate.path] : undefined } as PopulateOptions)
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -294,7 +294,7 @@ abstract class SearchFlow {
|
|
|
294
294
|
|
|
295
295
|
if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
|
|
296
296
|
for (var populate of this.populate) {
|
|
297
|
-
result[0].items = await model.populate(result[0].items, { populate, select: this.projection[populate.path] } as PopulateOptions)
|
|
297
|
+
result[0].items = await model.populate(result[0].items, { ...populate, select: this.projection ? this.projection[populate.path] : undefined } as PopulateOptions)
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose"
|
|
2
|
-
import {
|
|
2
|
+
import { isNotEmpty } from "../../utils/Utils"
|
|
3
3
|
|
|
4
4
|
class BuildSelectSingleFlowItem {
|
|
5
5
|
|
|
@@ -21,13 +21,12 @@ class BuildSelectSingleFlowItem {
|
|
|
21
21
|
buildProjectionNested(model: mongoose.Model<any>, projectCurrent: any, field: string, include: boolean) {
|
|
22
22
|
let [first, ...rest] = field.split('.')
|
|
23
23
|
|
|
24
|
-
if (
|
|
24
|
+
if (isNotEmpty(first) && isNotEmpty(rest)){
|
|
25
25
|
|
|
26
26
|
const campoInfo = model.schema.path(first);
|
|
27
27
|
|
|
28
28
|
// Verifique se o tipo do campo é mongoose.Types.ObjectId
|
|
29
29
|
if (campoInfo.instance === "ObjectID") {
|
|
30
|
-
console.log('O campo é um Types.ObjectId');
|
|
31
30
|
return undefined
|
|
32
31
|
}
|
|
33
32
|
}
|