gpt4 book ai didi

mysql - 当sequelize.import模型时,表名末尾似乎有一个额外的 's'

转载 作者:行者123 更新时间:2023-11-30 00:17:12 25 4
gpt4 key购买 nike

我使用actionhero + sequelize加上mysql。当我这样做时

var sequelize = new Sequelize("MJN", "testUser", "testPasss", {
"host": "192.168.123.321",
"dialect": "mysql",
"port": 3306,
"pool": {
"maxConnections": 20,
"maxIdleTime": 30000
}
});

var MJNCustomer = sequelize.import(__dirname + "/../models/MJNCustomer.js");

我执行 console.log(MJNCustomer.tableName);,它返回 MJNCustomers 而不是 MJNCustomer

这里是models/MJNCustomer.js

module.exports = function(sequelize, DataTypes) {
return sequelize.define('MJNCustomer', {
customerId: DataTypes.STRING,
fname: DataTypes.STRING,
lname: DataTypes.STRING,
address1: DataTypes.STRING,
address2: DataTypes.STRING,
city: DataTypes.STRING,
phoneNumber: DataTypes.STRING
});

}

我在这里做错了什么?

最佳答案

您现在可以使用ah-sequelize-plugin然后只需使用 api.models 对象访问您的模型。

Models are loaded into api.models, so the example above would be api.models.Project. These module.exports allow for a third optional parameter "api" which is the ActionHero API object. This can be used to access configs and initializer functions, among other things.

关于mysql - 当sequelize.import模型时,表名末尾似乎有一个额外的 's',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23559365/

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