Files
backend/src/models/Scan.ts
2020-12-02 17:40:03 +01:00

45 lines
751 B
TypeScript

import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from "typeorm";
import {
IsBoolean,
IsInt,
IsNotEmpty,
IsOptional,
IsPositive,
} from "class-validator";
import { Runner } from "./Runner";
/**
* Defines the scan interface.
*/
@Entity()
export abstract class Scan {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsOptional()
@IsInt()
id: number;
/**
* The associated runner.
*/
@IsNotEmpty()
@ManyToOne(() => Runner, runner => runner.scans)
runner: Runner;
/**
* The scan's distance in meters.
*/
@IsInt()
@IsPositive()
abstract distance: number;
/**
* Is the scan valid (for fraud reasons).
*/
@Column()
@IsBoolean()
valid: boolean;
}