- Strapi Version:
- Operating System:
- Node Version:
- NPM Version:
- Yarn Version:
Hi, imagin We have two field in a model called A and B. I want to calculate their sum A+B as C and then sort results based on C. So this can be done using raw query in a custom route. But if I want to add this to all the existing apis I was thinking to use an database subscriber class and modify events in beforeFind and beforeFineMany hooks. This works well if I want to add that calculated field to the select part of query. However I cannot add it to the orderBy part due to the fact that strapi query builder does not suppoer knex raws in orderBy section.
Is there any way to solve this?
Is there any way that I get query from strapi query builder and modify it and then pass query results to the strapi sanitizer?