I am currently working on translating this SQL query into TypeORM using the QueryBuilder
:
SELECT
user_places.user_id,
place.mpath
FROM
public.user_root_places_place user_places
INNER JOIN
public.place place
ON place.id = user_places.place_id
The entities involved are:
@Entity()
export class User {
@Column({ unique: true, primary: true })
id: string;
@ManyToMany(() => Place)
@JoinTable()
rootPlaces: Place[];
}
@Entity()
export class Place {
@PrimaryGeneratedColumn()
id: number;
@Column()
mpath: string;
}
When creating a query builder, it is necessary to use an entity or table, but the join table may not be directly accessible in TypeORM
I understand that switching the order of the inner join table can resolve the issue, however I am specifically interested in cases where the source table is also the join table