c2-mongoose 2.1.455 → 2.1.456
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;
|
|
29
|
-
var
|
|
28
|
+
var _c, _d, _e, _f, _g, _h;
|
|
29
|
+
var _j = populateField.split('.'), first = _j[0], rest = _j.slice(1);
|
|
30
30
|
var fieldDefinition = GetFieldDefinitionFlowItem_1.default.execute(modelRoot, first);
|
|
31
31
|
if (!fieldDefinition)
|
|
32
32
|
return;
|
|
@@ -49,7 +49,7 @@ var PopulateV3FlowItem = /** @class */ (function () {
|
|
|
49
49
|
if (!((_c = fieldDefinition === null || fieldDefinition === void 0 ? void 0 : fieldDefinition.options) === null || _c === void 0 ? void 0 : _c.ref) && !((_e = (_d = fieldDefinition === null || fieldDefinition === void 0 ? void 0 : fieldDefinition.options) === null || _d === void 0 ? void 0 : _d.type[0]) === null || _e === void 0 ? void 0 : _e.ref)) {
|
|
50
50
|
throw new Error("[1]No reference found for populate field: ".concat(populateField));
|
|
51
51
|
}
|
|
52
|
-
var modelName = (_f = fieldDefinition.options.ref) !== null && _f !== void 0 ? _f : fieldDefinition.options.type[0].ref;
|
|
52
|
+
var modelName = (_f = fieldDefinition.options.ref) !== null && _f !== void 0 ? _f : (_g = fieldDefinition.options.type[0]) === null || _g === void 0 ? void 0 : _g.ref;
|
|
53
53
|
var refModel = global.connectionMongoose.model(modelName);
|
|
54
54
|
var collectionName = refModel.collection.name;
|
|
55
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; })) {
|
|
@@ -81,7 +81,7 @@ var PopulateV3FlowItem = /** @class */ (function () {
|
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
fieldDefinition = refModel.schema.path(nextField);
|
|
84
|
-
if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.ref) {
|
|
84
|
+
if (!fieldDefinition || !fieldDefinition.options || !((_h = fieldDefinition.options.type[0]) === null || _h === void 0 ? void 0 : _h.ref)) {
|
|
85
85
|
throw new Error("[1]No reference found for populate field: ".concat(populateField));
|
|
86
86
|
}
|
|
87
87
|
modelName = fieldDefinition.options.ref;
|
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@ class PopulateV3FlowItem {
|
|
|
43
43
|
throw new Error(`[1]No reference found for populate field: ${populateField}`);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
let modelName = fieldDefinition.options.ref ?? fieldDefinition.options.type[0]
|
|
46
|
+
let modelName = fieldDefinition.options.ref ?? fieldDefinition.options.type[0]?.ref;
|
|
47
47
|
let refModel = (global as any).connectionMongoose.model(modelName);
|
|
48
48
|
let collectionName = refModel.collection.name;
|
|
49
49
|
|
|
@@ -80,7 +80,7 @@ class PopulateV3FlowItem {
|
|
|
80
80
|
}
|
|
81
81
|
fieldDefinition = refModel.schema.path(nextField);
|
|
82
82
|
|
|
83
|
-
if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.ref) {
|
|
83
|
+
if (!fieldDefinition || !fieldDefinition.options || !fieldDefinition.options.type[0]?.ref) {
|
|
84
84
|
throw new Error(`[1]No reference found for populate field: ${populateField}`);
|
|
85
85
|
}
|
|
86
86
|
modelName = fieldDefinition.options.ref;
|