backend/src/models/entities/RunnerGroup.ts

47 lines
990 B
TypeScript

import {
IsInt,
IsNotEmpty,
IsOptional,
IsString
} from "class-validator";
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn, TableInheritance } from "typeorm";
import { GroupContact } from "./GroupContact";
import { Runner } from "./Runner";
/**
* Defines the runnerGroup interface.
*/
@Entity()
@TableInheritance({ column: { name: "type", type: "varchar" } })
export abstract class RunnerGroup {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsInt()
id: number;
/**
* The group's name.
*/
@Column()
@IsNotEmpty()
@IsString()
name: string;
/**
* The group's contact.
* Optional
*/
@IsOptional()
@ManyToOne(() => GroupContact, contact => contact.groups, { nullable: true })
contact?: GroupContact;
/**
* Used to link runners to a runner group.
*/
@OneToMany(() => Runner, runner => runner.group, { nullable: true })
runners: Runner[];
public abstract getRunners();
}