gpt4 book ai didi

node.js - 在 mysql phpmyadmin 中找不到表

转载 作者:行者123 更新时间:2023-12-03 22:38:22 29 4
gpt4 key购买 nike

我在 mysql phpmyadmin.i 中创建了一个数据库,将 Canvas 作为数据库,将学生作为表。我使用 Sequelize 创建了一个 ORM,它一直说找不到表我正在使用 postman 发布到表它应该给我电子邮件和消息的回复。这是 postman 错误,正在收到 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
}

)

最佳答案

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


}

)

这一行 - 'student', { 在你的模型定义中 student 是表名不是 student 因此错误 - Table 'canvas.students' 不存在

关于node.js - 在 mysql phpmyadmin 中找不到表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54997534/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com