[Deep Filtering] How to filter data with nested fields?

I have 2 content types, user and event. user is structured as below. How to filter user that the latest event with status: good?
{
id: 123,
name: abc,
events:[{id:1, status: good}, {id:2, status: poor}, {id:3, status: ok}]
}

If there is no direct query, do I need to build a custom route according to the doc
: Parameters Can someone show me an example of building a custom route? Thanks!

Hey there. I was just monitoring this thread but I see noone else has responded. Have you made any headway? Iā€™m not an expert, but this might be helpful to you:

If I understand you correctly, it sounds like you can either fetch all users and filter on the front end based on subdata, or build a custom controller function that fetches the data you want, as per the above link.

1 Like

normally its a good advise to have a properly model for your needs. Query Filter you find here:

When events are blowing up, I would propose to use some property like lastEvent and dont store events in your user model. Events are normally short lived data which will raise something and then vanish.

Also yes you can write your own controller.

Thanks! I end up writing a custom controller
This tutorial Using And Operator with Strapi Endpoint by using Custom Controller - YouTube is very helpful

1 Like