【问题标题】:"error": "relation \"Issueds\" does not exist"“错误”:“关系\“问题\”不存在”
【发布时间】:2020-05-15 03:17:32
【问题描述】:

我正在尝试插入我已经拥有的表中,但 sequelize 给我一个错误,表名已更改 表名 = 已发布

{
    "status": 500,
    "error": "relation \"Issueds\" does not exist"
}

【问题讨论】:

    标签: node.js sequelize.js


    【解决方案1】:

    Sequelize 默认复数表名。
    只需在模型配置对象中启用freezeTableName

    在您的模型定义中:

    module.exports = (sequelize, DataTypes) => {
        const Issued = sequelize.define(
        'Issued',
        {
            id: {
                type: DataTypes.INTEGER,
                autoIncrement: true,
                primaryKey: true
            },
            // Any other fields ...
        },
        {
            freezeTableName: true // This will prevent the name's pluralization.
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2021-09-21
      • 2018-07-26
      • 1970-01-01
      • 1970-01-01
      • 2015-08-18
      • 2019-10-26
      • 2018-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多