Code + comment cleanup for the entities

ref #39
This commit is contained in:
2020-12-21 15:29:32 +01:00
parent a03f1a438d
commit d20d738218
21 changed files with 156 additions and 87 deletions

View File

@@ -1,7 +1,6 @@
import {
IsInt,
IsNotEmpty,
IsPositive,
IsString
} from "class-validator";
@@ -10,7 +9,7 @@ import { ScanStation } from "./ScanStation";
import { TrackScan } from "./TrackScan";
/**
* Defines a track of given length.
* Defines the Track entity.
*/
@Entity()
export class Track {
@@ -23,6 +22,7 @@ export class Track {
/**
* The track's name.
* Mainly here for UX.
*/
@Column()
@IsString()
@@ -31,6 +31,7 @@ export class Track {
/**
* The track's length/distance in meters.
* Will be used to calculate runner's ran distances.
*/
@Column()
@IsInt()
@@ -38,13 +39,15 @@ export class Track {
distance: number;
/**
* Used to link scan stations to track.
* Used to link scan stations to a certain track.
* This makes the configuration of the scan stations easier.
*/
@OneToMany(() => ScanStation, station => station.track, { nullable: true })
stations: ScanStation[];
/**
* Used to link track scans to a track.
* The scan will derive it's distance from the track's distance.
*/
@OneToMany(() => TrackScan, scan => scan.track, { nullable: true })
scans: TrackScan[];