ff-admin-server/src/entity/unit/equipment/equipment.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-05-24 11:31:15 +02:00
import { Column, ColumnType, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { getTypeByORM } from "../../../migrations/ormHelper";
2025-05-25 07:01:13 +02:00
import { equipmentType } from "./equipmentType";
import { damageReport } from "../damageReport";
2025-05-24 11:31:15 +02:00
@Entity()
2025-05-25 07:01:13 +02:00
export class equipment {
2025-05-24 11:31:15 +02:00
@PrimaryGeneratedColumn("uuid")
id: string;
2025-05-26 14:53:25 +02:00
@Column({ type: "varchar", length: 255, nullable: true, default: null, unique: true })
2025-05-24 11:31:15 +02:00
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;
2025-05-26 14:53:25 +02:00
@Column({ type: getTypeByORM("datetime").type as ColumnType, nullable: true, default: null })
2025-05-24 11:31:15 +02:00
decommissioned?: Date;
@Column()
equipmentTypeId: string;
2025-05-25 07:01:13 +02:00
@ManyToOne(() => equipmentType, {
2025-05-24 11:31:15 +02:00
nullable: false,
onDelete: "RESTRICT",
onUpdate: "RESTRICT",
})
2025-05-25 07:01:13 +02:00
equipmentType: equipmentType;
2025-05-24 11:31:15 +02:00
2025-05-25 07:01:13 +02:00
@OneToMany(() => damageReport, (d) => d.equipment, { cascade: ["insert"] })
reports: damageReport[];
2025-05-24 11:31:15 +02:00
}