import { BeforeInsert , BeforeUpdate , Column , Entity } from 'typeorm' ; import { PrimaryGeneratedColumn } from 'typeorm/index' ; import { BaseModel } from './BaseModel' ; import moment = require ( 'moment' ) ; @ Entity ( 'manufacturer' ) export class Manufacturer extends BaseModel { @ PrimaryGeneratedColumn ( { name : 'manufacturer_id' } ) public manufacturerId : number ; @ Column ( { name : 'name' } ) public name : string ; @ Column ( { name : 'image' } ) public image : string ; @ Column ( { name : 'image_path' } ) public imagePath : string ; @ Column ( { name : 'sort_order' } ) public sortOrder : number ; @ Column ( { name : 'is_active' } ) public isActive : 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' ) ; } }