Javascript 无法读取属性';getTableName';未定义的
我试图在2个表之间建立连接,并使用两个表中的字段创建where子句,但出现以下错误:Javascript 无法读取属性';getTableName';未定义的,javascript,node.js,sequelize.js,Javascript,Node.js,Sequelize.js,我试图在2个表之间建立连接,并使用两个表中的字段创建where子句,但出现以下错误: Cannot read property 'getTableName' of undefined 这是我的模型: module.exports = function(sequelize, DataTypes) { var AutomatedCampaign = sequelize.define("AutomatedCampaign", { id: { type: DataT
Cannot read property 'getTableName' of undefined
这是我的模型:
module.exports = function(sequelize, DataTypes) {
var AutomatedCampaign = sequelize.define("AutomatedCampaign", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
campaign_name: DataTypes.STRING,
campaign_label: DataTypes.STRING,
medium: DataTypes.STRING,
visible: DataTypes.INTEGER,
}, {
tableName: 'automated_campaigns',
underscored: true,
timestamps: true,
}
);
return AutomatedCampaign;
};
module.exports = function(sequelize, DataTypes) {
var AutomatedCampaignConfig = sequelize.define("AutomatedCampaignConfig", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
environment_hash: DataTypes.STRING,
campaign_id: DataTypes.STRING,
event_trigger_1: DataTypes.STRING,
time_trigger_after_event_1: DataTypes.STRING,
event_constraint_1: DataTypes.STRING,
event_value_1: DataTypes.STRING,
event_timestamp_1: DataTypes.INTEGER,
is_deleted: DataTypes.BOOLEAN,
is_active: DataTypes.BOOLEAN,
html_content: DataTypes.TEXT,
has_product_feed: DataTypes.BOOLEAN,
subject_line: DataTypes.STRING,
}, {
tableName: 'automated_campaign_configs',
underscored: true,
timestamps: true,
classMethods: {
associate : function(models) {
AutomatedCampaignConfig.belongsTo(models.AutomatedCampaign, {foreignKey: 'campaign_id'})
},
},
}
);
return AutomatedCampaignConfig;
};
这是我的问题:
var AutomatedCampaign = require('../models/index').AutomatedCampaign;
var AutomatedCampaignConfig = require('../models/index').AutomatedCampaignConfig;
var values = {
include: [{
model: AutomatedCampaign,
through: { where: { visible: 1, environment_hash: environment_hash } }
}]
};
AutomatedCampaignConfig
.findAll(values)
.then(function(automated_campaigns) {
console.log('automated campaigns');
console.log(automated_campaigns);
});
可能有帮助,我在右窗格中看到:可能的重复您找到了解决方案了吗?可能有帮助,我在右窗格中看到:可能的重复您找到了解决方案了吗?