gpt4 book ai didi

node.js - Postgres 和 Sequelize - 无法读取未定义的属性 'name'

转载 作者:行者123 更新时间:2023-11-29 13:23:59 25 4
gpt4 key购买 nike

我正在尝试将在 MySQL 上运行良好的项目中的数据库更改为 Postgres。
我在运行迁移时收到以下错误(同步和 Sequelize db:migrate)。

/myProject/node_modules/pg/lib/connection.js:109
self.emit(msg.name, msg);
^

TypeError: Cannot read property 'name' of undefined
at Socket.<anonymous> (/myProject/node_modules/pg/lib/connection.js:109:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:172:18)
at Socket.Readable.push (_stream_readable.js:130:10)
at TCP.onread (net.js:542:20)

我只隔离了这个简单的模型,但我仍然得到错误

module.exports = (sequelize, DataTypes) => {
var User = sequelize.define('User', {
email: {
type: DataTypes.STRING,
validate: {
isEmail: true
}
},
googleId: {
type: DataTypes.STRING,
allowNull: false
}
}, {
underscored: true
})

return User
}

可能是什么问题?

最佳答案

我必须将连接字符串更改为此,现在它可以工作了。谢谢。

var sequelize = new Sequelize(match[5], match[1], match[2], {
dialect: 'postgres',
protocol: 'postgres',
port: match[4],
host: match[3],
logging: false,
dialectOptions: {
ssl: true
}
})

关于node.js - Postgres 和 Sequelize - 无法读取未定义的属性 'name',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37146183/

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