Added relations for RunnerTeams

ref #11
This commit is contained in:
Nicolai Ort 2020-12-01 19:51:16 +01:00
parent 7ac46a7cc7
commit 0d9d72c223
2 changed files with 9 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import {
} from "class-validator";
import { GroupContact } from "./GroupContact";
import { Runner } from "./Runner";
import { RunnerTeam } from "./RunnerTeam";
/**
* Defines the runnerGroup interface.
@ -42,4 +43,10 @@ export abstract class RunnerGroup {
*/
@OneToMany(() => Runner, runner => runner.group)
runners: Runner[];
/**
* Used to link teams to runner groups.
*/
@OneToMany(() => RunnerTeam, team => team.parentGroup)
teams: RunnerTeam[];
}

View File

@ -1,4 +1,4 @@
import { Entity, Column } from "typeorm";
import { Entity, Column, ManyToOne } from "typeorm";
import { IsNotEmpty } from "class-validator";
import { RunnerGroup } from "./RunnerGroup";
@ -14,6 +14,6 @@ export class RunnerTeam extends RunnerGroup {
*/
@Column()
@IsNotEmpty()
//TODO: Relationship
@ManyToOne(() => RunnerGroup, group => group.teams)
parentGroup?: RunnerGroup;
}