Inside my collection type controller I want to filter results based on business logic.
The standard way is this, which I expect:
async find(ctx) {
const entries = await strapi.entityService.findMany('api::restaurant.restaurant', {
filters: ...,
});
}
Problem is, that restaurants has to be filtered by a deeper logic inside multiple relations and by userrole.
So I tried filtering after fetching.
Here an example with find:
async find(ctx) {
const results = await super.find(ctx);
results.data = filterPublicRestaurants(ctx, results.data);
return results;
}
The problem is that the meta pagination no longer fits the data.
Is there a better way to filter data based on business logic?