c2-mongoose 2.1.209 → 2.1.210

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.
@@ -10,11 +10,8 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
13
  Object.defineProperty(exports, "__esModule", { value: true });
17
- var mongoose_1 = __importDefault(require("mongoose"));
14
+ var Utils_1 = require("../../utils/Utils");
18
15
  var BuildSelectSingleFlowItem = /** @class */ (function () {
19
16
  function BuildSelectSingleFlowItem() {
20
17
  }
@@ -30,10 +27,10 @@ var BuildSelectSingleFlowItem = /** @class */ (function () {
30
27
  };
31
28
  BuildSelectSingleFlowItem.prototype.buildProjectionNested = function (model, projectCurrent, field, include) {
32
29
  var _a = field.split('.'), first = _a[0], rest = _a.slice(1);
33
- if (first !== undefined && rest !== undefined) {
30
+ if ((0, Utils_1.isEmpty)(first) && (0, Utils_1.isEmpty)(rest)) {
34
31
  var campoInfo = model.schema.path(first);
35
32
  // Verifique se o tipo do campo é mongoose.Types.ObjectId
36
- if (campoInfo instanceof mongoose_1.default.Schema.Types.ObjectId) {
33
+ if (campoInfo.instance === "ObjectID") {
37
34
  console.log('O campo é um Types.ObjectId');
38
35
  return undefined;
39
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.209",
3
+ "version": "2.1.210",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,5 @@
1
1
  import mongoose from "mongoose"
2
+ import { isEmpty } from "../../utils/Utils"
2
3
 
3
4
  class BuildSelectSingleFlowItem {
4
5
 
@@ -20,12 +21,12 @@ class BuildSelectSingleFlowItem {
20
21
  buildProjectionNested(model: mongoose.Model<any>, projectCurrent: any, field: string, include: boolean) {
21
22
  let [first, ...rest] = field.split('.')
22
23
 
23
- if (first !== undefined && rest !== undefined){
24
+ if (isEmpty(first) && isEmpty(rest)){
24
25
 
25
26
  const campoInfo = model.schema.path(first);
26
27
 
27
28
  // Verifique se o tipo do campo é mongoose.Types.ObjectId
28
- if (campoInfo instanceof mongoose.Schema.Types.ObjectId) {
29
+ if (campoInfo.instance === "ObjectID") {
29
30
  console.log('O campo é um Types.ObjectId');
30
31
  return undefined
31
32
  }