import { IsNotEmpty } from "class-validator";
import { ChildEntity, ManyToOne } from "typeorm";
import { RunnerGroup } from "./RunnerGroup";
import { RunnerOrganisation } from "./RunnerOrganisation";

/**
 * Defines the RunnerTeam entity.
 * This usually is a school class or department in a company.
*/
@ChildEntity()
export class RunnerTeam extends RunnerGroup {

  /**
   * The team's parent group.
   * Every team has to be part of a runnerOrganisation - this get's checked on creation and update.
   */
  @IsNotEmpty()
  @ManyToOne(() => RunnerOrganisation, org => org.teams, { nullable: true })
  parentGroup?: RunnerOrganisation;
}