egg结合sequelize--模型定义中去除 createAt、updateAt字段,驼峰

版权声明:feixie https://blog.csdn.net/qq_36850813/article/details/89641846
module.exports = app => {

  const { STRING, INTEGER, DATE } = app.Sequelize;

  const Announces = app.model.define('announces', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    title: { type: STRING, allowNull: false },
    content: { type: STRING, allowNull: false },
    isTop: { type: INTEGER, defaultValue: 1, field: 'is_top' },
    createDate: { type: DATE, field: 'create_date' },
    createBy: { type: STRING, field: 'create_by' },
    updateDate: { type: DATE, field: 'update_date' },  //field 转驼峰
    updateBy: { type: STRING, field: 'update_by' },

  }, {
    timestamps: false,  //去除createAt updateAt
    freezeTableName: true,  使用自定义表名
  });

  return Announces;

};

猜你喜欢

转载自blog.csdn.net/qq_36850813/article/details/89641846