27 lines
763 B
TypeScript
27 lines
763 B
TypeScript
import { IsNotEmpty } from "class-validator";
|
|
import { ChildEntity, getConnectionManager, ManyToOne } from "typeorm";
|
|
import { Runner } from './Runner';
|
|
import { RunnerGroup } from "./RunnerGroup";
|
|
import { RunnerOrganisation } from "./RunnerOrganisation";
|
|
|
|
/**
|
|
* Defines a runner team (class or deparment for example).
|
|
*/
|
|
@ChildEntity()
|
|
export class RunnerTeam extends RunnerGroup {
|
|
|
|
/**
|
|
* The team's parent group.
|
|
* Optional
|
|
*/
|
|
@IsNotEmpty()
|
|
@ManyToOne(() => RunnerOrganisation, org => org.teams, { nullable: false })
|
|
parentGroup?: RunnerOrganisation;
|
|
|
|
/**
|
|
* Returns all runners associated with this team.
|
|
*/
|
|
public async getRunners() {
|
|
return await getConnectionManager().get().getRepository(Runner).find({ group: this });
|
|
}
|
|
} |