TypeORM 时间处理
@Column({
name: 'deleted_at',
type: 'timestamp',
transformer: {
to(时间戳) {
// 这里一定要判断一下!!!
return 时间戳 ? dayjs(时间戳).toDate() : 时间戳;
},
from(数据库对象) {
return +dayjs(数据库对象);
},
},
})
deleted?: number;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14