поэтому у меня есть проблема, с которой я не могу справиться, может быть, вы могли бы мне помочь. Итак: у меня есть три объекта - User, Team, UserTeam, которые содержат (userId, teamId, teamRole). UserTeam — это сущность, содержащая составной первичный ключ. как в коде ниже:
@Index(["teamId", "userId"], { unique: true })
export class UserTeam {
@PrimaryColumn("int")
userId = undefined;
@PrimaryColumn("int")
teamId = undefined;
@ManyToOne(type => Team)
team = undefined;
@ManyToOne(type => User)
user = undefined;
@Column({
type: 'enum',
enum: ['CAPITAN', 'PLAYER'],
})
teamRole = "";
}
export class Team {
@PrimaryGeneratedColumn()
id = undefined;
@OneToMany(type => UserTeam, userTeam => userTeam.user)
userTeams = undefined;
export class User {
@PrimaryGeneratedColumn()
id = undefined;
@OneToMany(type => UserTeam, userTeam => userTeam.team)
teams = undefined;
}
Итак -> я хотел бы создать запрос, который вернет мне всех игроков (пользователей) из определенной команды. поэтому я создаю запрос типа eq ({team_id: 1, player: {userId: 1, userId: 21, userId: 34} (вместо идентификаторов я хотел бы иметь объекты, это просто пример.
getRepository(Team).createQueryBuilder("team")
.leftJoin("team.users", "userTeam")
.leftJoin("userTeam.user", "user")
.getMany()
который возвращает мне ЗАПРОС:
SELECT "team"."id" AS "team_id", "team"."name" AS "team_name", "team"."shortcut" AS "team_shortcut", "team"."nationality" AS "team_nationality", "team"."description" AS "team_description", "team"."imagePath" AS "team_imagePath", "team"."division" AS "team_division" FROM "team" "team" LEFT JOIN "user_team" "userTeam" ON "userTeam"."userId" = "team"."id" LEFT JOIN "user" "user" ON "user"."id" = "userTeam"."userId"
И проблема в том, что у меня есть
LEFT JOIN "user_team" "userTeam" ON "userTeam"."userId" = "team"."id"```
Вместо
userTeam.teamId=team.id
У вас есть идеи, как решить мою проблему? Буду очень рад любым советам и подсказкам.



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Проблема решена. У меня было обратное отношение. мне следует иметь
@OneToMany(type => UserTeam, userTeam => userTeam.user)
teams = undefined;
@OneToMany(type => UserTeam, userTeam => userTeam.team)
users = undefined;