c2-mongoose 2.1.329 → 2.1.330

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.
@@ -8,11 +8,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8
8
  }
9
9
  return to.concat(ar || Array.prototype.slice.call(from));
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- var mongoose_1 = __importDefault(require("mongoose"));
16
12
  var PopulateFlowItem = /** @class */ (function () {
17
13
  function PopulateFlowItem() {
18
14
  }
@@ -46,7 +42,7 @@ var PopulateFlowItem = /** @class */ (function () {
46
42
  throw new Error("[1]No reference found for populate field: ".concat(populateField));
47
43
  }
48
44
  var modelName = fieldDefinition.options.ref;
49
- var refModel = mongoose_1.default.model(modelName);
45
+ var refModel = global.connectionMongoose.model(modelName);
50
46
  var collectionName = refModel.collection.name;
51
47
  if (!populateClauses.some(function (populateClause) { var _a; return ((_a = populateClause === null || populateClause === void 0 ? void 0 : populateClause.$lookup) === null || _a === void 0 ? void 0 : _a.localField) === first; })) {
52
48
  var populateClauseLookup = [
@@ -81,7 +77,7 @@ var PopulateFlowItem = /** @class */ (function () {
81
77
  throw new Error("[1]No reference found for populate field: ".concat(populateField));
82
78
  }
83
79
  modelName = fieldDefinition.options.ref;
84
- refModel = mongoose_1.default.model(modelName);
80
+ refModel = global.connectionMongoose.model(modelName);
85
81
  collectionName = refModel.collection.name;
86
82
  var populateClauseLookup = [
87
83
  {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compareDesc = exports.compareAsc = exports.isNotIterable = exports.isIterable = exports.isEmpty = exports.isNotEmpty = exports.getLoggerRepository = exports.initialize = void 0;
4
4
  var Logger_1 = require("../model/Logger");
5
5
  var initialize = function (connection) {
6
+ global.connectionMongoose = connection;
6
7
  global.LoggerRepository = connection.model('c2-mongoose-logger', Logger_1.LoggerModel);
7
8
  };
8
9
  exports.initialize = initialize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.329",
3
+ "version": "2.1.330",
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",
@@ -33,7 +33,7 @@ class PopulateFlowItem {
33
33
  }
34
34
 
35
35
  let modelName = fieldDefinition.options.ref;
36
- let refModel = mongoose.model(modelName);
36
+ let refModel = (global as any).connectionMongoose.model(modelName);
37
37
  let collectionName = refModel.collection.name;
38
38
 
39
39
  if (!populateClauses.some((populateClause: any) => populateClause?.$lookup?.localField === first)) {
@@ -73,7 +73,7 @@ class PopulateFlowItem {
73
73
  throw new Error(`[1]No reference found for populate field: ${populateField}`);
74
74
  }
75
75
  modelName = fieldDefinition.options.ref;
76
- refModel = mongoose.model(modelName);
76
+ refModel = (global as any).connectionMongoose.model(modelName);
77
77
  collectionName = refModel.collection.name;
78
78
 
79
79
  const populateClauseLookup: any = [
@@ -2,6 +2,7 @@ import mongoose, { Connection } from "mongoose"
2
2
  import { LoggerModel } from "../model/Logger"
3
3
 
4
4
  export const initialize = (connection: Connection) => {
5
+ (global as any).connectionMongoose = connection;
5
6
  (global as any).LoggerRepository = connection.model('c2-mongoose-logger', LoggerModel)
6
7
  }
7
8