diff --git a/src/models/entities/GroupContact.ts b/src/models/entities/GroupContact.ts index f650259..d2b0abe 100644 --- a/src/models/entities/GroupContact.ts +++ b/src/models/entities/GroupContact.ts @@ -7,10 +7,9 @@ import { IsString } from "class-validator"; -import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm"; +import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm"; import { config } from '../../config'; import { Address } from "./Address"; -import { IAddressUser } from './IAddressUser'; import { RunnerGroup } from "./RunnerGroup"; /** @@ -18,7 +17,7 @@ import { RunnerGroup } from "./RunnerGroup"; * Mainly it's own class to reduce duplicate code and enable contact's to be associated with multiple groups. */ @Entity() -export class GroupContact implements IAddressUser { +export class GroupContact { /** * Autogenerated unique id (primary key). */ @@ -55,7 +54,7 @@ export class GroupContact implements IAddressUser { * This is a address object to prevent any formatting differences. */ @IsOptional() - @ManyToOne(() => Address, address => address.addressUsers, { nullable: true }) + @Column(type => Address) address?: Address; /** diff --git a/src/models/entities/IAddressUser.ts b/src/models/entities/IAddressUser.ts deleted file mode 100644 index 3d8eaf9..0000000 --- a/src/models/entities/IAddressUser.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Entity, ManyToOne, PrimaryColumn } from 'typeorm'; -import { Address } from './Address'; - -/** - * The interface(tm) all entities using addresses have to implement. - * This is a abstract class, because apparently typeorm can't really work with interfaces :/ - */ -@Entity() -export abstract class IAddressUser { - @PrimaryColumn() - id: number; - - @ManyToOne(() => Address, address => address.addressUsers, { nullable: true }) - address?: Address - - /** - * Turns this entity into it's response class. - */ - public abstract toResponse(); -} diff --git a/src/models/entities/Participant.ts b/src/models/entities/Participant.ts index fa40a8f..ccf7656 100644 --- a/src/models/entities/Participant.ts +++ b/src/models/entities/Participant.ts @@ -7,11 +7,10 @@ import { IsString } from "class-validator"; -import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm"; +import { Column, Entity, PrimaryGeneratedColumn, TableInheritance } from "typeorm"; import { config } from '../../config'; import { ResponseParticipant } from '../responses/ResponseParticipant'; import { Address } from "./Address"; -import { IAddressUser } from './IAddressUser'; /** * Defines the Participant entity. @@ -19,7 +18,7 @@ import { IAddressUser } from './IAddressUser'; */ @Entity() @TableInheritance({ column: { name: "type", type: "varchar" } }) -export abstract class Participant implements IAddressUser { +export abstract class Participant { /** * Autogenerated unique id (primary key). */ @@ -55,7 +54,7 @@ export abstract class Participant implements IAddressUser { * The participant's address. * This is a address object to prevent any formatting differences. */ - @ManyToOne(() => Address, address => address.addressUsers, { nullable: true }) + @Column(type => Address) address?: Address; /** diff --git a/src/models/entities/RunnerOrganisation.ts b/src/models/entities/RunnerOrganisation.ts index ebae8fd..e5f3330 100644 --- a/src/models/entities/RunnerOrganisation.ts +++ b/src/models/entities/RunnerOrganisation.ts @@ -1,8 +1,7 @@ import { IsInt, IsOptional } from "class-validator"; -import { ChildEntity, ManyToOne, OneToMany } from "typeorm"; +import { ChildEntity, Column, OneToMany } from "typeorm"; import { ResponseRunnerOrganisation } from '../responses/ResponseRunnerOrganisation'; import { Address } from './Address'; -import { IAddressUser } from './IAddressUser'; import { Runner } from './Runner'; import { RunnerGroup } from "./RunnerGroup"; import { RunnerTeam } from "./RunnerTeam"; @@ -12,13 +11,13 @@ import { RunnerTeam } from "./RunnerTeam"; * This usually is a school, club or company. */ @ChildEntity() -export class RunnerOrganisation extends RunnerGroup implements IAddressUser { +export class RunnerOrganisation extends RunnerGroup { /** * The organisations's address. */ @IsOptional() - @ManyToOne(() => Address, address => address.addressUsers, { nullable: true }) + @Column(type => Address) address?: Address; /**