'How can I create columns with type Date and type DateTime in nestjs with typeORM?
I am new with nestjs. How can I set columns that accepts Date format and dateTime format?
Not in both cases, the columns are two differents column, one accept Date and other dateTime.
Solution 1:[1]
How about ?
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
EDIT
You can find more info here
Solution 2:[2]
To add more to this ticket as DateTime was not even mentioned:
/**
* Start DateTime
*/
@Column({
type: 'datetime',
default: () => 'NOW()',
})
@Index()
start: string;
/**
* End DateTime
*/
@Column({
type: 'datetime',
nullable: true,
})
@Index()
end: string;
This is for those not wanting or needing to use
@CreateDateColumn()
@UpdateDateColumn()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Jeremy |
