pangea-server 1.0.20 → 1.0.21
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,12 +206,9 @@ 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
|
-
console.log(`----- currentDepth: ${currentDepth} -----`);
|
|
215
212
|
const maxDepth = rel.joinDepth;
|
|
216
213
|
if (currentDepth >= maxDepth)
|
|
217
214
|
continue;
|
|
@@ -223,14 +220,14 @@ function getIncludeAndWhere(model, includeItems, where, relDepth = new Map(), pa
|
|
|
223
220
|
const newRelDepth = new Map(relDepth);
|
|
224
221
|
newRelDepth.set(relKey, currentDepth + 1);
|
|
225
222
|
const relModel = rel.getModelFn();
|
|
226
|
-
|
|
223
|
+
const nestedResult = getIncludeAndWhere(relModel, nestedIncludeItems, relWhere, newRelDepth, relKey);
|
|
227
224
|
includeOptions.push({
|
|
228
225
|
model: relModel,
|
|
229
226
|
as: relName,
|
|
230
227
|
required: rel.required,
|
|
231
228
|
paranoid: rel.paranoid,
|
|
232
|
-
|
|
233
|
-
...
|
|
229
|
+
include: nestedResult.include,
|
|
230
|
+
...(nestedResult.where && { where: nestedResult.where }),
|
|
234
231
|
});
|
|
235
232
|
}
|
|
236
233
|
return {
|