import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, ChildEntity } from "typeorm"; import { IsBoolean, IsDateString, IsInt, IsNotEmpty, IsOptional, IsPositive, } from "class-validator"; import { Scan } from "./Scan"; import { Runner } from "./Runner"; import { Track } from "./Track"; import { RunnerCard } from "./RunnerCard"; import { ScanStation } from "./ScanStation"; /** * Defines the scan interface. */ @ChildEntity() export class TrackScan extends Scan { /** * The associated track. */ @IsNotEmpty() @ManyToOne(() => Track, track => track.scans, { nullable: true }) track: Track; /** * The associated card. */ @IsNotEmpty() @ManyToOne(() => RunnerCard, card => card.scans, { nullable: true }) card: RunnerCard; /** * The scanning station. */ @IsNotEmpty() @ManyToOne(() => ScanStation, station => station.scans, { nullable: true }) station: ScanStation; /** * The scan's distance in meters. */ @IsInt() @IsPositive() public get distance(): number { return this.track.distance; } /** * The scan's creation timestamp. */ @Column() @IsDateString() @IsNotEmpty() timestamp: string; }