import { Column , PrimaryGeneratedColumn , Entity , BeforeUpdate , BeforeInsert } from 'typeorm' ; import { BaseModel } from './BaseModel' ; import moment = require ( 'moment/moment' ) ; @ Entity ( 'contact' ) export class Contact extends BaseModel { @ PrimaryGeneratedColumn ( ) public id : number ; @ Column ( { name : 'name' } ) public name : string ; @ Column ( { name : 'email' } ) public email : string ; @ Column ( { name : 'phone_number' } ) public phoneNumber : string ; @ Column ( { name : 'message' } ) public message : string ; @ 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' ) ; } }