我正在使用最新版本的sequelize,只需找到“ Venue”模型时就急于加载模型“ VenueAddress”,但出现以下错误:

我感谢您的帮助。

TypeError: Cannot read property 'replace' of undefined
at Object.module.exports.removeTicks (d:\GitProjects\bashed\node_modules\sequelize\lib\utils.js:595:13)
at Object.module.exports.addTicks


//查找方法:

db.Venue.find({ where: {venueId: id},include: [{model: db.VenueAddress}]}).then(function(venue){
if(!venue) {
return next(new Error('Failed to load venue ' + id));
} else {
req.venue = venue;
return next();
}
}).catch(function(err){
return next(err);
});


//楷模

Venue.hasMany(models.VenueAddress, {through: models.VenueAddress,foreignKey: 'venueId'});

VenueAddress.belongsTo(models.Venue, {through: models.VenueAddress,foreignKey: 'venueId'});

最佳答案

请参考以下链接:
https://github.com/sequelize/sequelize/issues/3331#issuecomment-80886227


  mickhansen说:看来您需要删除穿透属性
  来自您的Venue.hasMany关联,因为它不是N:M关联。

10-06 01:32