Custom controller, find on related data

System Information
  • Strapi Version: 4.1.12
  • Operating System: Win10
  • Database: sqlite
  • Node Version: v16.15.0
  • NPM Version: 8.5.5
  • Yarn Version: 1.22.15

Hello,

I’m trying to create a custom controller funcion to find on related data but keep getting all records.

Any suggestion?

This is the function code:

async getLessonsByInterest(ctx) {

  const { interest } = ctx.params
  let entities = await strapi.service('api::lesson.lesson').find({ 'interest.id': interest }, populate);
  console.log(entities)

}

I should get the list of lessons with the specified interest id but it’s not working.

Thank you

I think you couldn’t call Entity Service API like this.

const entries = await strapi.entityService.findMany('api::article.article', {
  fields: ['title', 'description'],
  filters: { title: 'Hello World' },
  sort: { createdAt: 'DESC' },
  populate: { category: true },
});