import { IsNotEmpty } from 'class-validator' ; import { BeforeInsert , BeforeUpdate , Column , Entity , OneToMany , PrimaryGeneratedColumn } from 'typeorm' ; import { BaseModel } from './BaseModel' ; import moment = require ( 'moment' ) ; import { Order } from './Order' ; @ Entity ( 'order_status' ) export class OrderStatus extends BaseModel { @ PrimaryGeneratedColumn ( { name : 'order_status_id' } ) public orderStatusId : number ; @ IsNotEmpty ( ) @ Column ( { name : 'name' } ) public name : string ; @ Column ( { name : 'is_active' } ) public isActive : number ; @ OneToMany ( type => Order , order => order . orderStatus ) public statusOfOrder : Order [ ] ; @ Column ( { name : 'color_code' } ) public colorCode : string ; @ BeforeInsert ( ) public async createDetails ( ) { this . createdDate = moment ( ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ; } @ BeforeUpdate ( ) public async updateDetails ( ) { this . modifiedDate = moment ( ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ; } }