From a2cf8d1f2c4a2087e2dd6c297bea1a46db4220f9 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 1 Dec 2020 17:16:50 +0100 Subject: [PATCH] Switched from implementing the "interfaces" as interface to abstract classes ref #11 This was done to take advantage of typeorm and class validator --- src/models/IScan.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/models/IScan.ts b/src/models/IScan.ts index 6906c5c..fdd6541 100644 --- a/src/models/IScan.ts +++ b/src/models/IScan.ts @@ -1,19 +1,35 @@ +import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"; +import { + IsInt, + IsNotEmpty, + IsOptional, + IsPositive, +} from "class-validator"; + /** * Defines the scan interface. */ -export interface IScan { +export abstract class IScan { /** * Autogenerated unique id (primary key). */ + @PrimaryGeneratedColumn() + @IsOptional() + @IsInt() id: number; /** * The associated runner. */ + @Column() + @IsNotEmpty() runner: Runner; /** * The scan's distance in meters. */ + @Column() + @IsInt() + @IsPositive() distance: number; }