pangea-server 1.0.27 → 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,15 +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
|
-
|
|
226
|
-
console.log('----- getIncludeAndWhere -----');
|
|
227
|
-
console.log(getIncludeAndWhere(relModel, nestedIncludeItems, relWhere, newRelDepth, relKey));
|
|
223
|
+
const nested = getIncludeAndWhere(relModel, nestedIncludeItems, relWhere, newRelDepth, relKey);
|
|
228
224
|
includeOptions.push({
|
|
229
225
|
model: relModel,
|
|
230
226
|
as: relName,
|
|
231
227
|
required: rel.required,
|
|
232
228
|
paranoid: rel.paranoid,
|
|
233
|
-
|
|
229
|
+
include: nested.include,
|
|
230
|
+
...(nested.where && { where: nested.where }),
|
|
234
231
|
});
|
|
235
232
|
}
|
|
236
233
|
return {
|