pangea-server 1.0.26 → 1.0.28
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.
|
@@ -206,10 +206,8 @@ function convertWhereKeys(obj) {
|
|
|
206
206
|
function getIncludeAndWhere(model, includeItems, where, relDepth = new Map(), parentKey = model.name) {
|
|
207
207
|
const includeOptions = [];
|
|
208
208
|
const cleanWhere = { ...where };
|
|
209
|
-
console.log(`----- Model: ${model.name} -----`);
|
|
210
209
|
for (const [relName, rel] of Object.entries(model.Relations)) {
|
|
211
210
|
const relKey = `${parentKey}->${relName}`;
|
|
212
|
-
console.log(`----- relKey: ${relKey} -----`);
|
|
213
211
|
const currentDepth = relDepth.get(relKey) || 0;
|
|
214
212
|
const maxDepth = rel.joinDepth;
|
|
215
213
|
if (currentDepth >= maxDepth)
|
|
@@ -222,13 +220,14 @@ function getIncludeAndWhere(model, includeItems, where, relDepth = new Map(), pa
|
|
|
222
220
|
const newRelDepth = new Map(relDepth);
|
|
223
221
|
newRelDepth.set(relKey, currentDepth + 1);
|
|
224
222
|
const relModel = rel.getModelFn();
|
|
225
|
-
|
|
223
|
+
const nested = getIncludeAndWhere(relModel, nestedIncludeItems, relWhere, newRelDepth, relKey);
|
|
226
224
|
includeOptions.push({
|
|
227
225
|
model: relModel,
|
|
228
226
|
as: relName,
|
|
229
227
|
required: rel.required,
|
|
230
228
|
paranoid: rel.paranoid,
|
|
231
|
-
|
|
229
|
+
include: nested.include,
|
|
230
|
+
...(nested.where && { where: nested.where }),
|
|
232
231
|
});
|
|
233
232
|
}
|
|
234
233
|
return {
|