import { IsNotEmpty } from 'class-validator' ; import { BeforeInsert , Column , Entity , BeforeUpdate , PrimaryGeneratedColumn } from 'typeorm' ; import { BaseModel } from './BaseModel' ; import moment from 'moment' ; @ Entity ( 'order_total' ) export class OrderTotal extends BaseModel { @ PrimaryGeneratedColumn ( ) public order_total_id : number ; @ IsNotEmpty ( ) @ Column ( { name : 'order_id' } ) public orderId : number ; @ IsNotEmpty ( ) @ Column ( { name : 'value' } ) public value : number ; @ 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' ) ; } }