diff --git a/src/models/ScanStation.ts b/src/models/ScanStation.ts index 2989be0..cd317af 100644 --- a/src/models/ScanStation.ts +++ b/src/models/ScanStation.ts @@ -1,4 +1,4 @@ -import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"; +import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from "typeorm"; import { IsBoolean, IsInt, @@ -34,7 +34,7 @@ export class ScanStation { */ @Column() @IsNotEmpty() - //TODO: Relation + @ManyToOne(() => Track, track => track.stations) track: Track; /** diff --git a/src/models/Track.ts b/src/models/Track.ts index d5aeaa5..e8689a4 100644 --- a/src/models/Track.ts +++ b/src/models/Track.ts @@ -1,4 +1,4 @@ -import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"; +import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from "typeorm"; import { IsInt, IsNotEmpty, @@ -6,6 +6,7 @@ import { IsPositive, IsString, } from "class-validator"; +import { ScanStation } from "./ScanStation"; /** * Defines a track of given length. @@ -35,4 +36,10 @@ export class Track { @IsInt() @IsPositive() distance: number; + + /** + * Used to link scan stations to track. + */ + @OneToMany(() => ScanStation, station => station.track) + stations: ScanStation[]; }