定义关联关系:
Theme.belongsToMany(Product,{through:theme_product,foreignKey:'theme_id'})
Product.belongsToMany(Theme,{through:theme_product,foreignKey:'product_id'})
theme_product为中间表
报错信息:
throw new Error(this.name + '.belongsToMany called with something that\'snot a subclass of Sequelize.Model');
^
Error: Theme.belongsToMany called with something that's not a subclass of Sequelize.Model
问题已经解决,两个模型并不在同一个sequelize实例下。
参考该项目:https://segmentfault.com/a/11...