I want to provide some additional argument in named modifier, but when I'm calling it this way
query.midify('filters', [filter_query])
it's try to find named modifier with [filter_query].
Is it expected behavior?
Cannot reproduce based on your example. Works on my tests.
@koskimas Maybe my example wasn't so clear.
My model file:
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.
Most helpful comment
As a workaround, you can use the query context