-
Notifications
You must be signed in to change notification settings - Fork 642
Closed
Description
I'd like to propose to add a way for a model class to provide a catch-all modifier for the case when a requested modifier isn't defined / found. Something along these lines:
class MyModel extends Model {
...
static modifierNotFound(builder, modifier) {
// Do something with the modifier and the query, and return the builder if it was
// handled, nullish otherwise, indicating Objection should still throw an error.
const { properties } = this.getJsonSchema()
if (properties && modifier in properties) {
return builder.select(modifier)
}
}
}Optionally it could also just return a boolean.
I think this could open the door to many more creative uses of eager expressions and modifiers, and would be a pretty great feature that could be added with very little overhead. I'd be happy to create a PR for it.
@koskimas what do you think?
Metadata
Metadata
Assignees
Labels
No labels