c2-mongoose 2.1.424 → 2.1.425

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,7 +25,8 @@ var PopulateFlowItem = /** @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 = populateField.split('.'), first = _c[0], rest = _c.slice(1);
28
+ var _c, _d;
29
+ var _e = populateField.split('.'), first = _e[0], rest = _e.slice(1);
29
30
  var fieldDefinition = GetFieldDefinitionFlowItem_1.default.execute(modelRoot, first);
30
31
  if (!fieldDefinition)
31
32
  return;
@@ -45,10 +46,10 @@ var PopulateFlowItem = /** @class */ (function () {
45
46
  // if ((typeFirst === 'Array') && !rest?.length) {
46
47
  // return
47
48
  // }
48
- if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.ref) {
49
+ if (!fieldDefinition || !fieldDefinition.options || (!fieldDefinition.options.ref && !((_c = fieldDefinition.options.type) === null || _c === void 0 ? void 0 : _c.ref))) {
49
50
  throw new Error("[1]No reference found for populate field: ".concat(populateField));
50
51
  }
51
- var modelName = fieldDefinition.options.ref;
52
+ var modelName = (_d = fieldDefinition.options.ref) !== null && _d !== void 0 ? _d : fieldDefinition.options.type.ref;
52
53
  var refModel = global.connectionMongoose.model(modelName);
53
54
  var collectionName = refModel.collection.name;
54
55
  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; })) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.424",
3
+ "version": "2.1.425",
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",
@@ -39,11 +39,11 @@ class PopulateFlowItem {
39
39
  // }
40
40
 
41
41
 
42
- if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.ref) {
42
+ if (!fieldDefinition || !fieldDefinition.options || (!fieldDefinition.options.ref && !fieldDefinition.options.type?.ref)) {
43
43
  throw new Error(`[1]No reference found for populate field: ${populateField}`);
44
44
  }
45
45
 
46
- let modelName = fieldDefinition.options.ref;
46
+ let modelName = fieldDefinition.options.ref ?? fieldDefinition.options.type.ref;
47
47
  let refModel = (global as any).connectionMongoose.model(modelName);
48
48
  let collectionName = refModel.collection.name;
49
49