52 lines
951 B
TypeScript
52 lines
951 B
TypeScript
import {
|
|
IsInt,
|
|
IsNotEmpty,
|
|
|
|
IsPositive,
|
|
IsString
|
|
} from "class-validator";
|
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
|
import { ScanStation } from "./ScanStation";
|
|
import { TrackScan } from "./TrackScan";
|
|
|
|
/**
|
|
* Defines a track of given length.
|
|
*/
|
|
@Entity()
|
|
export class Track {
|
|
/**
|
|
* Autogenerated unique id (primary key).
|
|
*/
|
|
@PrimaryGeneratedColumn()
|
|
@IsInt()
|
|
id: number;;
|
|
|
|
/**
|
|
* The track's name.
|
|
*/
|
|
@Column()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
name: string;
|
|
|
|
/**
|
|
* The track's length/distance in meters.
|
|
*/
|
|
@Column()
|
|
@IsInt()
|
|
@IsPositive()
|
|
distance: number;
|
|
|
|
/**
|
|
* Used to link scan stations to track.
|
|
*/
|
|
@OneToMany(() => ScanStation, station => station.track, { nullable: true })
|
|
stations: ScanStation[];
|
|
|
|
/**
|
|
* Used to link track scans to a track.
|
|
*/
|
|
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
|
|
scans: TrackScan[];
|
|
}
|