mysql phpmyadmin中找不到表

时间:2019-03-05 07:31:35

标签: node.js express sequelize.js

我在mysql phpmyadmin中创建了一个数据库。我将画布作为数据库,将学生作为表。我使用Sequelize创建了一个ORM,它一直说找不到该表。我正在使用邮递员将其发布到该表,它应该给我电子邮件和消息的响应。这是邮递员错误,正在errorSequelizeDatabaseError: Table 'canvas.students' doesn't exist谢谢。

这是我的db.js

const Sequelize = require('sequelize');
const db = {}
const sequelize = new Sequelize('canvas', 'root', 'root', {
    host: 'localhost',
    port: 8889,
    dialect: 'mysql',
    operatorAliases: false,

    pool: {
        max: 5,
        min: 0,
        acquire: 3000,
        idle: 10000
    }
})
db.sequelize = sequelize
db.Squelize = Sequelize

module.exports = db;

这是我的模型

 const Sequelize = require('sequelize');
const db = require('../database/db.js')

module.exports = db.sequelize.define(
    'student', {
        id: {
            type: Sequelize.INTEGER,
            primaryKey: true,
            autoIncrement: true
        },
        name: {
            type: Sequelize.STRING
        },
        email: {
            type: Sequelize.STRING
        },
        password: {
            type: Sequelize.STRING
        },
        created: {
            type: Sequelize.DATE,
            defaultValue: Sequelize.NOW
        }
    }, {
        timestamps: false
    }

)

1 个答案:

答案 0 :(得分:0)

module.exports = db.sequelize.define(
'student', {
    id: {
        type: Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    name: {
        type: Sequelize.STRING
    },
    email: {
        type: Sequelize.STRING
    },
    password: {
        type: Sequelize.STRING
    },
    created: {
        type: Sequelize.DATE,
        defaultValue: Sequelize.NOW
    }
}, {
    timestamps: false


  }

)

此行-模型定义学生中的“学生” {”是表名,而不是学生,因此出现错误-表'canvas.students'不存在