Include and filter by properties in nested relations
See original GitHub issueHi,
I’m trying to get relations to work with nested relations. Let’s say I have entities A, B, and C.
A has a Many-to-One to B, and B has a One-to-One to C.
If I am using the pagination on A, but trying to filter by values on C, it looks like I can’t.
relations option seems to only accept “surface” relations, and I’ve been trying to build a custom query builder but even if I can manage to include these relations, filtering seems to still be broken.
Am I missing something? Thanks.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (2 by maintainers)
Top Results From Across the Web
c# - Filtering with EF Core through multiple nested object ...
I assume you have relation between Reports and UserReportFilter tables since you have ReportId in UserReportFilter table.
Read more >How to filter nested relations · Discussion #2980 · mikro-orm ...
How to filter nested relations. ... The bookings received should only be the bookings that have the property createdBy equal to the provided...
Read more >Relation queries (Concepts) - Prisma
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
Read more >Filter on (nested) relationship attribute? - JSON API
Another I'm wondering is how to filter on nested relationships. ... The value of the include parameter MUST be a comma-separated (U+002C ...
Read more >Filtering relations / nested relations in Notion : r/Notion - Reddit
I want to have the following properties: a. name - no problem here b. client (relation) - no problem here either
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@FlyingOddo @ppetzold Hey! Apologies for forgetting to do the PR. As I had to make some more changes I have to check that the tests are passing I will do it as soon as possible.
Hi all, it seems I found a workaround for nested relations
The main idea is to use custom queryBuilder which will mask needed relation as core entity’s relation
Assume the following relations between entities:
User -> Photos -> Commentsand we need to filter bycomments.likesproperty. When we will usecomments.likesinfilterorsearchByquery – nestjs-paginate will try to finduser.commentsproperty inuser_commentstable name – and use our manual left join! PROFIT!Snipper to illustrate the idea (at least smth like that works in my project):