Limiting find to only return associated results

System Information
  • Strapi Version: v4
  • Operating System: OSX
  • Database: Postgres 14
  • Node Version: v17.6.0
  • NPM Version: 8.5.1

Hi… Hoping for some advice. Let’s say you have a Delivery collection and it has a From and To relation fields that each map to a User type (from users-permissions). I’d like to allow an authenticated user to query the REST API for any deliveries it’s associated with. Where would be the appropriate place to implement this? A middleware? Custom implementation of find? Should this be a different route altogether, e.g /api/users/me/deliveries?

E.g, The route in question is /api/deliveries. A Delivery object has a from and to relation fields. An authenticated user queries the above endpoint, and I’d like him to only see results where from or to has him as the value of the field.