Hi,
is it possible to modify a filter value before the SQL is executed.
For example if a model has a string field, the user can select the field in the filter view and enter a string value. I want to change that string value, so that the new one is used in the SQL query.
Is there a hook, would it be possible to solve this via custom datatype or is there another solution?
Hi @bef To achieve your goal you can do something like this in the routes/your-collection.js file
// Get a list of YourCollection
router.get('/your-collection', permissionMiddlewareCreator.list(), (request, response, next) => {
// see request.query.filters
next();
});
Hi, I have a follow up question to this one.
changing the request.query.filters works fine for the collection filter.
The problem is it seems not to work for related data.
Let’s say I have a parent-collection which has a relation to child-collection. I can navigate to the child-collection via “Related Data” in the parent-collection view.
But when I enter a filter there, the GET route of child-collection is not called (where I do my query changes). That means the filter mechanisms seems to work differently there.
Am I missing something, or is there another route I have to change?