From 7ac46a7cc75618f5c01c46d3baee83c30d124124 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 1 Dec 2020 19:48:20 +0100 Subject: [PATCH] Added relations to RunnerOrganisation --- src/models/Address.ts | 7 +++++++ src/models/RunnerOrganisation.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/models/Address.ts b/src/models/Address.ts index 723bac9..59e6570 100644 --- a/src/models/Address.ts +++ b/src/models/Address.ts @@ -7,6 +7,7 @@ import { IsString, } from "class-validator"; import { Participant } from "./Participant"; +import { RunnerOrganisation } from "./RunnerOrganisation"; /** * Defines a address (to be used for contact information). @@ -77,4 +78,10 @@ export class Address { */ @OneToMany(() => Participant, participant => participant.address) participants: Participant[]; + + /** + * Used to link the address to runner groups. + */ + @OneToMany(() => RunnerOrganisation, group => group.address) + groups: RunnerOrganisation[]; } diff --git a/src/models/RunnerOrganisation.ts b/src/models/RunnerOrganisation.ts index 3166964..d3e4ea8 100644 --- a/src/models/RunnerOrganisation.ts +++ b/src/models/RunnerOrganisation.ts @@ -1,4 +1,4 @@ -import { Entity, Column } from "typeorm"; +import { Entity, Column, ManyToOne } from "typeorm"; import { IsOptional,} from "class-validator"; import { RunnerGroup } from "./RunnerGroup"; import { Address } from "./Address"; @@ -15,6 +15,6 @@ export class RunnerOrganisation extends RunnerGroup { */ @Column() @IsOptional() - //TODO: Relationship + @ManyToOne(() => Address, address => address.groups) address?: Address; } \ No newline at end of file