Add ability to load votes by id

Use createDate and updateDate as strings
This commit is contained in:
Jerko Steiner 2019-04-08 13:33:55 +08:00
parent 17d67900c1
commit e509c32f79
2 changed files with 10 additions and 4 deletions

View File

@ -12,6 +12,7 @@ app:
db:
type: sqlite
database: data/data.db
timezone: 'Z'
synchronize: false
dropSchema: false
migrationsRun: false

View File

@ -4,13 +4,18 @@ import {
UpdateDateColumn,
} from 'typeorm'
const transformer = {
from: (value: Date) => value.toISOString(),
to: (value: undefined | null | string) => value ? new Date(value) : value,
}
export abstract class BaseEntity {
@PrimaryGeneratedColumn({type: 'bigint'})
id!: number
@CreateDateColumn()
createDate!: Date
@CreateDateColumn({transformer, type: 'datetime'})
createDate!: string
@UpdateDateColumn()
updateDate!: Date
@UpdateDateColumn({transformer, type: 'datetime'})
updateDate!: string
}