Issue with Filtering Data Based on Relations


I’m currently working on a project using Strapi and I’m having some issues with filtering data based on relations.

I have a Fixture model with homeTeam and awayTeam fields, both of which have a oneToOne relation with the Team model. I’m trying to filter Fixtures based on the homeTeam or awayTeam ID, but I’m encountering some issues.

Here’s the code I’m using:

`const query = {{
filters: {{
$or: [
{{ ‘’: {{ $in: => }} }}, // also tried hardcoding [6] here for testing
{{ ‘’: {{ $in: => }} }}, // also tried hardcoding [6] here for testing
populate: [‘homeTeam’, ‘awayTeam’],

const {{ results, pagination }} = await strapi.entityService.findMany(‘api::fixture.fixture’, query);
return {{ results, pagination }};`

In this code, managedTeams is a list of User.managedTeams IDs.

When I try to run this code, I get a 404 error. I’ve checked my data and relations, and everything seems to be set up correctly. The homeTeam and awayTeam fields in my Fixture data correspond to valid id values in the Team model, and homeTeam and awayTeam are correctly set up as relations in my model.

I’ve also tried populating the homeTeam and awayTeam relations using the populate option in the findMany method, but I’m still getting a 404 error.

I’m not sure what I’m doing wrong here. Any help would be greatly appreciated.

Thank you!

This topic has been created from a Discord post (1222529976889380914) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord