Skip to content
Advertisement

Typeorm Postgres select where double nested relation is equal to value

I have a relation like the following:

Match
id
teams
teams
id
players
players
id
name

From here I want to select the match that has the player name ‘x’.

Currently I have the following:

But this returns only a single team and single player that matches my where.

This match of id: 1 actually has more than 1 team and in each team there is more than 1 player but it only returns a single entity of each.

I need it to return all teams and all players in the match which has this player playing in it. How can I do this?

Thanks!

Advertisement

Answer

I was able to solve my problem by using a subquery

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement