Added relations to RunnerGroup

ref #11
This commit is contained in:
Nicolai Ort 2020-12-01 19:44:51 +01:00
parent 029e4beaf5
commit f28b08ed65
2 changed files with 11 additions and 4 deletions

View File

@ -1,8 +1,15 @@
import { Entity } from "typeorm";
import { Entity, OneToMany } from "typeorm";
import { Participant } from "./Participant";
import { RunnerGroup } from "./RunnerGroup";
/**
* Defines a group's contact.
*/
@Entity()
export class GroupContact extends Participant{}
export class GroupContact extends Participant{
/**
* Used to link runners to donations.
*/
@OneToMany(() => RunnerGroup, group => group.contact)
groups: RunnerGroup[];
}

View File

@ -1,4 +1,4 @@
import { PrimaryGeneratedColumn, Column, OneToMany } from "typeorm";
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne } from "typeorm";
import {
IsInt,
IsNotEmpty,
@ -34,7 +34,7 @@ export abstract class RunnerGroup {
*/
@Column()
@IsOptional()
//TODO: Relationship
@ManyToOne(() => GroupContact, contact => contact.groups)
contact?: GroupContact;
/**