All things deletion for runner* now are clean af and cascadeing
ref #13
This commit is contained in:
@@ -42,6 +42,4 @@ export abstract class RunnerGroup {
|
||||
*/
|
||||
@OneToMany(() => Runner, runner => runner.group, { nullable: true })
|
||||
runners: Runner[];
|
||||
|
||||
public abstract getRunners();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { IsOptional } from "class-validator";
|
||||
import { ChildEntity, getConnectionManager, ManyToOne, OneToMany } from "typeorm";
|
||||
import { ChildEntity, ManyToOne, OneToMany } from "typeorm";
|
||||
import { Address } from "./Address";
|
||||
import { Runner } from './Runner';
|
||||
import { RunnerGroup } from "./RunnerGroup";
|
||||
import { RunnerTeam } from "./RunnerTeam";
|
||||
|
||||
@@ -24,27 +23,4 @@ export class RunnerOrganisation extends RunnerGroup {
|
||||
*/
|
||||
@OneToMany(() => RunnerTeam, team => team.parentGroup, { nullable: true })
|
||||
teams: RunnerTeam[];
|
||||
|
||||
|
||||
/**
|
||||
* Returns all runners associated with this organisation or it's teams.
|
||||
*/
|
||||
public async getRunners() {
|
||||
let runners: Runner[] = new Array<Runner>();
|
||||
const teams = await this.getTeams();
|
||||
|
||||
await teams.forEach(async team => {
|
||||
runners.push(... await team.getRunners());
|
||||
});
|
||||
await runners.push(... await getConnectionManager().get().getRepository(Runner).find({ group: this }));
|
||||
|
||||
return runners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all teams associated with this organisation.
|
||||
*/
|
||||
public async getTeams() {
|
||||
return await getConnectionManager().get().getRepository(RunnerTeam).find({ parentGroup: this });
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IsNotEmpty } from "class-validator";
|
||||
import { ChildEntity, getConnectionManager, ManyToOne } from "typeorm";
|
||||
import { Runner } from './Runner';
|
||||
import { ChildEntity, ManyToOne } from "typeorm";
|
||||
import { RunnerGroup } from "./RunnerGroup";
|
||||
import { RunnerOrganisation } from "./RunnerOrganisation";
|
||||
|
||||
@@ -17,11 +16,4 @@ export class RunnerTeam extends RunnerGroup {
|
||||
@IsNotEmpty()
|
||||
@ManyToOne(() => RunnerOrganisation, org => org.teams, { nullable: true })
|
||||
parentGroup?: RunnerOrganisation;
|
||||
|
||||
/**
|
||||
* Returns all runners associated with this team.
|
||||
*/
|
||||
public async getRunners() {
|
||||
return await getConnectionManager().get().getRepository(Runner).find({ group: this });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user