Filtering on Many-to-Many relationship

System Information
  • Strapi Version: 4.3.4
  • Database: agnostic (PGSQL or SQLite)

I have a model called section (plural sections) which has a many to many relationship with tag (plural tags). I want to be able to filter all tags that have are in a list that have a certain section.id value, but many-to-many filtering isn’t documented and my assumptions have been wrong. Here is my code:

      const tags = await strapi.entityService.findMany('api::tag.tag', {
        filters: {
          tag: {
            $in: tags,
          },
          sections: {
            id: {
              $eq: section.id
            }
          },
        }
      });

but it comes up empty and I’m a bit at a loss. The only answers I’ve found when searching involve writing raw queries, which isn’t something I’m willing to do since this app needs to be database agnostic

So it turns out I was looking at the wrong thing. This code would have worked except the code prior to this wasn’t saving the relationship in the first place as createMany() doesn’t work with relations