我需要有关嵌入式实体的帮助。到目前为止,这些是我的实体:
@Entity()
export class Match {
@PrimaryGeneratedColumn()
id: number;
@Column(type => TeamScore)
red: TeamScore;
@Column(type => TeamScore)
blue: TeamScore;
}
export class TeamScore {
@Column(type => Team)
team: Team;
@Column()
score: number;
}
export class Team {
@JoinColumn()
@ManyToOne(type => Player)
striker: Player;
@JoinColumn()
@ManyToOne(type => Player)
defender: Player;
}
@Entity()
export class Player {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
}
TypeORM为我创建了表。问题在match
表上。我期望这样的事情:
id | redTeamStrikerId | redTeamDefenderId | redScore | blueTeamStrikerId | blueTeamDefenderId | blueScore
但是我得到的是:
id | strikerId | defenderId | redScore | blueScore
我在做什么错了?