0%

Sequelize createdAt/updatedAt 改名

也可以仅启用 createdAt/updatedAt 之一,并为这些列提供自定义名称

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Foo extends Model {}
Foo.init(
{
/* attributes */
},
{
sequelize,

// don't forget to enable timestamps!
timestamps: true,

// I don't want createdAt
createdAt: false,

// I want updatedAt to actually be called updateTimestamp
updatedAt: 'updateTimestamp',
}
);