Sequelize use camel case in JS but underscores in table names

前端 未结 4 1179
暖寄归人
暖寄归人 2020-12-29 02:36

Is it possible to have column names be underscored (postgres) but have the JavaScript getters be camelCase per language standards?

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 02:56

    2019+

    In Sequelize v5 you can now use the underscored: true attribute


    const User = sequelize.define('User', {
        username: DataTypes.STRING,
        password: DataTypes.STRING
      }, {underscored: true});
    

    https://sequelize.org/master/class/lib/model.js~Model.html#static-method-init

提交回复
热议问题