How can i filter collection by count of a specific relation?

System Information
  • Strapi Version: 4.6.0
  • Operating System: Windows
  • Database: MYSQL
  • Node Version: 18
  • NPM Version: 6
  • Yarn Version:

Hey! How can i filter collection by count of a specific relation?

For example i want to get all brand with related fields(cars) by query from

Maybe there is some query like /brands?filters[cars].length or something like this?

Sadly enough is this currently not possible with strapi on the db layer
what you could do is get everyting from the db and them do all the filtering in javascript

I solved what i needed with /brands?filters[cars][id][$notNull]=true