-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named modifiers don't work with optional arguments #1293
Comments
Cannot reproduce based on your example. Works on my tests. |
@koskimas Maybe my example wasn't so clear. class Person extends Model {
staic modifiers = {
filters: (query, context) => query.where({ age: context.age })
}
} calling this modifier Person.query()
.modify('filters', { age: 21 }) I'm expecting to have { age: 21 } in my modifier second argument (context). But instead I doesn't have second argument at all (undefined); |
Oh, ok. Yeah, that's a known limitation with the modifiers. Fixing this is a breaking change and needs to wait for 2.0 |
As a workaround, you can use the query context class Person extends Model {
static modifiers = {
filters: query => query.where({ age: query.context().age })
}
}
Person.query()
.mergeContext({ age: 21 })
.modify('filters') |
Fixed in v2.0 branch. |
I want to provide some additional argument in named modifier, but when I'm calling it this way
it's try to find named modifier with [filter_query].
Is it expected behavior?
The text was updated successfully, but these errors were encountered: