47
src/models/entities/RunnerGroup.ts
Normal file
47
src/models/entities/RunnerGroup.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne, Entity, TableInheritance } from "typeorm";
|
||||
import {
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from "class-validator";
|
||||
import { GroupContact } from "./GroupContact";
|
||||
import { Runner } from "./Runner";
|
||||
import { RunnerTeam } from "./RunnerTeam";
|
||||
|
||||
/**
|
||||
* Defines the runnerGroup interface.
|
||||
*/
|
||||
@Entity()
|
||||
@TableInheritance({ column: { name: "type", type: "varchar" } })
|
||||
export abstract class RunnerGroup {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
*/
|
||||
@PrimaryGeneratedColumn()
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* The group's first 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[];
|
||||
}
|
||||
Reference in New Issue
Block a user