backend/src/models/ScanStation.ts

62 lines
1.1 KiB
TypeScript

import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from "typeorm";
import {
IsBoolean,
IsInt,
IsNotEmpty,
IsOptional,
IsString,
} from "class-validator";
import { Track } from "./Track";
import { TrackScan } from "./TrackScan";
/**
* ScannerStations have the ability to create scans for specific tracks.
*/
@Entity()
export class ScanStation {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The station's description.
*/
@Column({nullable: true})
@IsOptional()
@IsString()
description?: string;
/**
* The track this station is associated with.
*/
@IsNotEmpty()
@ManyToOne(() => Track, track => track.stations)
track: Track;
/**
* The station's api key.
*/
@Column()
@IsNotEmpty()
@IsString()
key: string;
/**
* Is the station enabled (for fraud reasons)?
* Default: true
*/
@Column()
@IsBoolean()
enabled: boolean = true;
/**
* Used to link track scans to a scan station.
*/
@OneToMany(() => TrackScan, scan => scan.track)
scans: TrackScan[];
}