Skip to content

Sequelize 中 createdAt/updatedAt 的重命名

Published: at 03:25 PMSuggest Changes

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

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',
  }
);

Previous Post
JS Echarts 地图颜色配置
Next Post
JavaScript 判断元素是否滚动到底部