52
src/models/entities/Track.ts
Normal file
52
src/models/entities/Track.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from "typeorm";
|
||||
import {
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsPositive,
|
||||
IsString,
|
||||
} from "class-validator";
|
||||
import { ScanStation } from "./ScanStation";
|
||||
import { TrackScan } from "./TrackScan";
|
||||
|
||||
/**
|
||||
* Defines a track of given length.
|
||||
*/
|
||||
@Entity()
|
||||
export class Track {
|
||||
/**
|
||||
* Autogenerated unique id (primary key).
|
||||
*/
|
||||
@PrimaryGeneratedColumn()
|
||||
@IsOptional()
|
||||
@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[];
|
||||
}
|
||||
Reference in New Issue
Block a user