diff --git a/src/models/GroupContact.ts b/src/models/GroupContact.ts index e243d00..3ed4e63 100644 --- a/src/models/GroupContact.ts +++ b/src/models/GroupContact.ts @@ -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{} \ No newline at end of file +export class GroupContact extends Participant{ + /** + * Used to link runners to donations. + */ + @OneToMany(() => RunnerGroup, group => group.contact) + groups: RunnerGroup[]; +} \ No newline at end of file diff --git a/src/models/RunnerGroup.ts b/src/models/RunnerGroup.ts index d619e2f..c35ad48 100644 --- a/src/models/RunnerGroup.ts +++ b/src/models/RunnerGroup.ts @@ -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; /**