Added basics for the runner team controller

ref #13
This commit is contained in:
2020-12-04 17:50:10 +01:00
parent 838cedfe6c
commit ca917b0577
4 changed files with 187 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import { Entity, Column, ManyToOne, ChildEntity } from "typeorm";
import { IsNotEmpty } from "class-validator";
import { ChildEntity, getConnectionManager, ManyToOne } from "typeorm";
import { Runner } from './Runner';
import { RunnerGroup } from "./RunnerGroup";
import { RunnerOrganisation } from "./RunnerOrganisation";
@@ -16,4 +17,12 @@ 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() {
let runnerRepo = await getConnectionManager().get().getRepository(Runner);
return await runnerRepo.find({ group: this });
}
}