import { Entity , Column , PrimaryGeneratedColumn , ManyToOne } from 'typeorm' ; import { LeaveRequest } from './LeaveRequest.entity' ; @ Entity ( ) export class Leave { @ PrimaryGeneratedColumn ( 'uuid' ) private id : string ; @ Column ( { type : 'integer' , nullable : false , comment : 'Stored in minutes' } ) private time : number ; @ Column ( { type : 'date' , nullable : false } ) private date : string ; @ ManyToOne ( type => LeaveRequest , { nullable : false , onDelete : 'CASCADE' } ) private leaveRequest : LeaveRequest ; constructor ( leaveRequest , time , date ) { this . leaveRequest = leaveRequest ; this . time = time ; this . date = date ; } public getId ( ) { return this . id ; } public getLeaveRequest ( ) { return this . leaveRequest ; } public getType ( ) { return `leave_${ this . leaveRequest . getType ( ) }` ; } public getTime ( ) { return this . time ; } public getDate ( ) { return this . date ; } }