42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
|
import { getTypeByORM } from "../../../migrations/ormHelper";
|
|
import { vehicleType } from "./vehicleType";
|
|
import { damageReport } from "../damageReport";
|
|
import { inspection } from "../inspection/inspection";
|
|
|
|
@Entity()
|
|
export class vehicle {
|
|
@PrimaryGeneratedColumn("uuid")
|
|
id: string;
|
|
|
|
@Column({ type: "varchar", length: 255, nullable: true, default: null, unique: true })
|
|
code?: string;
|
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
name: string;
|
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
location: string;
|
|
|
|
@Column({ type: getTypeByORM("date").type as ColumnType })
|
|
commissioned: Date;
|
|
|
|
@Column({ type: getTypeByORM("date").type as ColumnType, nullable: true, default: null })
|
|
decommissioned?: Date;
|
|
|
|
@Column()
|
|
vehicleTypeId: string;
|
|
|
|
@ManyToOne(() => vehicleType, {
|
|
nullable: false,
|
|
onDelete: "RESTRICT",
|
|
onUpdate: "RESTRICT",
|
|
})
|
|
vehicleType: vehicleType;
|
|
|
|
@OneToMany(() => damageReport, (d) => d.vehicle, { cascade: ["insert"] })
|
|
reports: damageReport[];
|
|
|
|
@OneToMany(() => inspection, (i) => i.vehicle)
|
|
inspections: inspection[];
|
|
}
|