import { Column, Entity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, VersionColumn, ManyToOne, } from 'typeorm'; import { Process } from './process.entity'; import { Product } from './product.entity'; @Entity() export class Unit { @PrimaryGeneratedColumn() id: number; @Column({ unique: true }) name: string; @Column({ nullable: true }) comment?: string; @ManyToOne( type => Process, process => process.units, { cascade: ['insert', 'update', 'soft-remove', 'recover'], nullable: true, eager: true, }, ) process: Process; @ManyToOne( type => Product, product => product.units, { cascade: ['insert', 'update', 'soft-remove', 'recover'], nullable: true, eager: true, }, ) product: Product; @CreateDateColumn() createdAt: Date; @UpdateDateColumn() updatedAt: Date; @DeleteDateColumn() deletedAt: Date; @VersionColumn() version: number; }