38 lines
1.1 KiB
TypeScript
38 lines
1.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, default: null, 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, default: null })
|
|
decommissioned?: Date;
|
|
|
|
@Column()
|
|
equipmentTypeId: string;
|
|
|
|
@ManyToOne(() => equipmentType, {
|
|
nullable: false,
|
|
onDelete: "RESTRICT",
|
|
onUpdate: "RESTRICT",
|
|
})
|
|
equipmentType: equipmentType;
|
|
|
|
@OneToMany(() => damageReport, (d) => d.equipment, { cascade: ["insert"] })
|
|
reports: damageReport[];
|
|
}
|