parent
9b5d16ae92
commit
2c47436259
@ -7,7 +7,7 @@ import {
|
|||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { Participant } from "./Participant";
|
import { IAddressUser } from './IAddressUser';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the Address entity.
|
* Defines the Address entity.
|
||||||
@ -78,13 +78,6 @@ export class Address {
|
|||||||
/**
|
/**
|
||||||
* Used to link the address to participants.
|
* Used to link the address to participants.
|
||||||
*/
|
*/
|
||||||
@OneToMany(() => Participant, participant => participant.address, { nullable: true })
|
@OneToMany(() => IAddressUser, addressUser => addressUser.address, { nullable: true })
|
||||||
participants: Participant[];
|
addressUsers: IAddressUser[];
|
||||||
|
|
||||||
//TODO: #68
|
|
||||||
// /**
|
|
||||||
// * Used to link the address to runner groups.
|
|
||||||
// */
|
|
||||||
// @OneToMany(() => RunnerOrganisation, group => group.address, { nullable: true })
|
|
||||||
// groups: RunnerOrganisation[];
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { Address } from "./Address";
|
import { Address } from "./Address";
|
||||||
|
import { IAddressUser } from './IAddressUser';
|
||||||
import { RunnerGroup } from "./RunnerGroup";
|
import { RunnerGroup } from "./RunnerGroup";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +18,7 @@ import { RunnerGroup } from "./RunnerGroup";
|
|||||||
* Mainly it's own class to reduce duplicate code and enable contact's to be associated with multiple groups.
|
* Mainly it's own class to reduce duplicate code and enable contact's to be associated with multiple groups.
|
||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
export class GroupContact {
|
export class GroupContact implements IAddressUser {
|
||||||
/**
|
/**
|
||||||
* Autogenerated unique id (primary key).
|
* Autogenerated unique id (primary key).
|
||||||
*/
|
*/
|
||||||
@ -54,7 +55,7 @@ export class GroupContact {
|
|||||||
* This is a address object to prevent any formatting differences.
|
* This is a address object to prevent any formatting differences.
|
||||||
*/
|
*/
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ManyToOne(() => Address, address => address.participants, { nullable: true })
|
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
||||||
address?: Address;
|
address?: Address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
11
src/models/entities/IAddressUser.ts
Normal file
11
src/models/entities/IAddressUser.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { Entity, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||||
|
import { Address } from './Address';
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export abstract class IAddressUser {
|
||||||
|
@PrimaryColumn()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
||||||
|
address?: Address
|
||||||
|
}
|
@ -10,6 +10,7 @@ import {
|
|||||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
|
||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { Address } from "./Address";
|
import { Address } from "./Address";
|
||||||
|
import { IAddressUser } from './IAddressUser';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the Participant entity.
|
* Defines the Participant entity.
|
||||||
@ -17,7 +18,7 @@ import { Address } from "./Address";
|
|||||||
*/
|
*/
|
||||||
@Entity()
|
@Entity()
|
||||||
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
||||||
export abstract class Participant {
|
export abstract class Participant implements IAddressUser {
|
||||||
/**
|
/**
|
||||||
* Autogenerated unique id (primary key).
|
* Autogenerated unique id (primary key).
|
||||||
*/
|
*/
|
||||||
@ -53,7 +54,7 @@ export abstract class Participant {
|
|||||||
* The participant's address.
|
* The participant's address.
|
||||||
* This is a address object to prevent any formatting differences.
|
* This is a address object to prevent any formatting differences.
|
||||||
*/
|
*/
|
||||||
@ManyToOne(() => Address, address => address.participants, { nullable: true })
|
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
||||||
address?: Address;
|
address?: Address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { IsInt } from "class-validator";
|
import { IsInt, IsOptional } from "class-validator";
|
||||||
import { ChildEntity, OneToMany } from "typeorm";
|
import { ChildEntity, ManyToOne, OneToMany } from "typeorm";
|
||||||
|
import { Address } from './Address';
|
||||||
|
import { IAddressUser } from './IAddressUser';
|
||||||
import { Runner } from './Runner';
|
import { Runner } from './Runner';
|
||||||
import { RunnerGroup } from "./RunnerGroup";
|
import { RunnerGroup } from "./RunnerGroup";
|
||||||
import { RunnerTeam } from "./RunnerTeam";
|
import { RunnerTeam } from "./RunnerTeam";
|
||||||
@ -9,14 +11,14 @@ import { RunnerTeam } from "./RunnerTeam";
|
|||||||
* This usually is a school, club or company.
|
* This usually is a school, club or company.
|
||||||
*/
|
*/
|
||||||
@ChildEntity()
|
@ChildEntity()
|
||||||
export class RunnerOrganisation extends RunnerGroup {
|
export class RunnerOrganisation extends RunnerGroup implements IAddressUser {
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * The organisations's address.
|
* The organisations's address.
|
||||||
// */
|
*/
|
||||||
// @IsOptional()
|
@IsOptional()
|
||||||
// @ManyToOne(() => Address, address => address.groups, { nullable: true })
|
@ManyToOne(() => Address, address => address.addressUsers, { nullable: true })
|
||||||
// address?: Address;
|
address?: Address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The organisation's teams.
|
* The organisation's teams.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user