import { Entity , PrimaryGeneratedColumn , Column } from 'typeorm' ; import * as moment from 'moment' ; @ Entity ( 'user_message' ) export class UserMessage { @ PrimaryGeneratedColumn ( ) id : number ; @ Column ( { name : 'content' , type : 'text' } ) content : string ; @ Column ( { transformer : { from : ( date ) => { return moment ( date ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ; } , to : ( date ) => { date = date ? date : new Date ( ) ; return moment ( date ) . format ( 'YYYY-MM-DD HH:mm:ss' ) ; } } } ) createdAt : string ; @ Column ( { nullable : true } ) owner : number ; @ Column ( { default : false } ) state : boolean ; }