ModelQuery: throw an error when fed with nonexistent relation
This commit is contained in:
parent
df651f2661
commit
97b2d3b94c
@ -183,6 +183,7 @@ export default class ModelQuery<M extends Model> {
|
|||||||
|
|
||||||
// Eager loading init map
|
// Eager loading init map
|
||||||
for (const relation of this.relations) {
|
for (const relation of this.relations) {
|
||||||
|
if (model[relation] === undefined) throw new Error(`Relation ${relation} doesn't exist on ${model.constructor.name}.`);
|
||||||
relationMap[relation].push(model[relation]);
|
relationMap[relation].push(model[relation]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user