This is my code:
@IsDate()
@ApiProperty({
type: Number,
})
updateTime: Date;
How can I add default value to current date
This is my code:
@IsDate()
@ApiProperty({
type: Number,
})
updateTime: Date;
How can I add default value to current date
From the docs, you can change your code to following:
@ApiProperty({
type: Number,
default: new Date().now() // or something else...
})
There is a separate annotation called UpdateDateColumn for storing updated date times.
@IsOptional({ groups: [CREATE, UPDATE] })
@UpdateDateColumn({ nullable: true })
updateTime: Date;
The import statement is as follows -
import { PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Column } from 'typeorm';