Mitigated circular dependency (to be fixed)

ref #65
This commit is contained in:
2021-01-02 18:12:18 +01:00
parent c9ba69792f
commit 1dc438beb2
8 changed files with 29 additions and 31 deletions

View File

@@ -8,7 +8,6 @@ import {
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { config } from '../../config';
import { Participant } from "./Participant";
import { RunnerOrganisation } from "./RunnerOrganisation";
/**
* Defines the Address entity.
@@ -82,9 +81,9 @@ export class Address {
@OneToMany(() => Participant, participant => participant.address, { nullable: true })
participants: Participant[];
/**
* Used to link the address to runner groups.
*/
@OneToMany(() => RunnerOrganisation, group => group.address, { nullable: true })
groups: RunnerOrganisation[];
// /**
// * Used to link the address to runner groups.
// */
// @OneToMany(() => RunnerOrganisation, group => group.address, { nullable: true })
// groups: RunnerOrganisation[];
}

View File

@@ -3,7 +3,7 @@ import {
IsNotEmpty
} from "class-validator";
import { Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
import { Participant } from "./Participant";
import { Donor } from './Donor';
/**
* Defines the Donation entity.
@@ -24,8 +24,8 @@ export abstract class Donation {
* The donations's donor.
*/
@IsNotEmpty()
@ManyToOne(() => Participant, donor => donor.donations)
donor: Participant;
@ManyToOne(() => Donor, donor => donor.donations)
donor: Donor;
/**
* The donation's amount in cents (or whatever your currency's smallest unit is.).

View File

@@ -1,5 +1,6 @@
import { IsBoolean } from "class-validator";
import { ChildEntity, Column } from "typeorm";
import { ChildEntity, Column, OneToMany } from "typeorm";
import { Donation } from './Donation';
import { Participant } from "./Participant";
/**
@@ -14,4 +15,11 @@ export class Donor extends Participant {
@Column()
@IsBoolean()
receiptNeeded: boolean = false;
/**
* Used to link the participant as the donor of a donation.
* Attention: Only runner's can be associated as a distanceDonations distance source.
*/
@OneToMany(() => Donation, donation => donation.donor, { nullable: true })
donations: Donation[];
}

View File

@@ -7,10 +7,9 @@ import {
IsString
} from "class-validator";
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
import { config } from '../../config';
import { Address } from "./Address";
import { Donation } from "./Donation";
/**
* Defines the Participant entity.
@@ -74,11 +73,4 @@ export abstract class Participant {
@IsOptional()
@IsEmail()
email?: string;
/**
* Used to link the participant as the donor of a donation.
* Attention: Only runner's can be associated as a distanceDonations distance source.
*/
@OneToMany(() => Donation, donation => donation.donor, { nullable: true })
donations: Donation[];
}

View File

@@ -1,6 +1,5 @@
import { IsInt, IsOptional } from "class-validator";
import { ChildEntity, ManyToOne, OneToMany } from "typeorm";
import { Address } from "./Address";
import { IsInt } from "class-validator";
import { ChildEntity, OneToMany } from "typeorm";
import { Runner } from './Runner';
import { RunnerGroup } from "./RunnerGroup";
import { RunnerTeam } from "./RunnerTeam";
@@ -12,12 +11,12 @@ import { RunnerTeam } from "./RunnerTeam";
@ChildEntity()
export class RunnerOrganisation extends RunnerGroup {
/**
* The organisations's address.
*/
@IsOptional()
@ManyToOne(() => Address, address => address.groups, { nullable: true })
address?: Address;
// /**
// * The organisations's address.
// */
// @IsOptional()
// @ManyToOne(() => Address, address => address.groups, { nullable: true })
// address?: Address;
/**
* The organisation's teams.