c2-mongoose 2.1.458 → 2.1.463

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.
@@ -25,8 +25,8 @@ var PopulateV3FlowItem = /** @class */ (function () {
25
25
  var populateClauses = [];
26
26
  populatesFields === null || populatesFields === void 0 ? void 0 : populatesFields.forEach(function (populateField) {
27
27
  var _a, _b;
28
- var _c, _d, _e, _f, _g, _h, _j, _k;
29
- var _l = populateField.split('.'), first = _l[0], rest = _l.slice(1);
28
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
29
+ var _m = populateField.split('.'), first = _m[0], rest = _m.slice(1);
30
30
  var fieldDefinition = GetFieldDefinitionFlowItem_1.default.execute(modelRoot, first);
31
31
  if (!fieldDefinition)
32
32
  return;
@@ -82,13 +82,13 @@ var PopulateV3FlowItem = /** @class */ (function () {
82
82
  break;
83
83
  }
84
84
  fieldDefinition = refModel.schema.path(nextField);
85
- if (!fieldDefinition || !fieldDefinition.options || !((_h = fieldDefinition.options.type[0]) === null || _h === void 0 ? void 0 : _h.ref)) {
85
+ if (!fieldDefinition || !fieldDefinition.options || !((_h = fieldDefinition.options) === null || _h === void 0 ? void 0 : _h.ref) || !((_j = fieldDefinition.options.type[0]) === null || _j === void 0 ? void 0 : _j.ref)) {
86
86
  throw new Error("[1]No reference found for populate field: ".concat(populateField));
87
87
  }
88
88
  if (!fieldDefinition)
89
89
  return;
90
90
  typeFirst = fieldDefinition.instance;
91
- modelName = (_j = fieldDefinition.options.ref) !== null && _j !== void 0 ? _j : (_k = fieldDefinition.options.type[0]) === null || _k === void 0 ? void 0 : _k.ref;
91
+ modelName = (_k = fieldDefinition.options.ref) !== null && _k !== void 0 ? _k : (_l = fieldDefinition.options.type[0]) === null || _l === void 0 ? void 0 : _l.ref;
92
92
  refModel = global.connectionMongoose.model(modelName);
93
93
  collectionName = refModel.collection.name;
94
94
  var populateClauseLookup = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.458",
3
+ "version": "2.1.463",
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",
@@ -81,7 +81,7 @@ class PopulateV3FlowItem {
81
81
  }
82
82
  fieldDefinition = refModel.schema.path(nextField);
83
83
 
84
- if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.type[0]?.ref) {
84
+ if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options?.ref || !fieldDefinition.options.type[0]?.ref) {
85
85
  throw new Error(`[1]No reference found for populate field: ${populateField}`);
86
86
  }
87
87