39 lines
1 KiB
TypeScript
39 lines
1 KiB
TypeScript
|
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||
|
import { getTypeByORM } from "../../../migrations/ormHelper";
|
||
|
import { EquipmentType } from "./equipmentType";
|
||
|
import { DamageReport } from "../damageReport";
|
||
|
|
||
|
@Entity()
|
||
|
export class Equipment {
|
||
|
@PrimaryGeneratedColumn("uuid")
|
||
|
id: string;
|
||
|
|
||
|
@Column({ type: "varchar", length: 255, nullable: true, unique: true })
|
||
|
code?: string;
|
||
|
|
||
|
@Column({ type: "varchar", length: 255 })
|
||
|
name: string;
|
||
|
|
||
|
@Column({ type: "varchar", length: 255 })
|
||
|
location: string;
|
||
|
|
||
|
@Column({ type: getTypeByORM("datetime").type as ColumnType })
|
||
|
commissioned: Date;
|
||
|
|
||
|
@Column({ type: getTypeByORM("datetime").type as ColumnType, nullable: true })
|
||
|
decommissioned?: Date;
|
||
|
|
||
|
@Column()
|
||
|
equipmentTypeId: string;
|
||
|
|
||
|
@ManyToOne(() => EquipmentType, {
|
||
|
nullable: false,
|
||
|
onDelete: "RESTRICT",
|
||
|
onUpdate: "RESTRICT",
|
||
|
})
|
||
|
equipmentType: EquipmentType;
|
||
|
|
||
|
@OneToMany(() => DamageReport, (d) => d.equipment, { cascade: ["insert"] })
|
||
|
reports: DamageReport[];
|
||
|
}
|