如何使用sequelize查找三个表数据?

时间:2018-11-22 12:58:30

标签: mysql sequelize.js

表格:

表关联:

 //category_product with category
category.hasMany(category_product,{foreignKey:'category_id'})
category_product.belongsTo(category,{foreignKey:'category_id'})

//category_product with Product
Product.hasMany(category_product,{foreignKey:'product_id'})
category_product.belongsTo(Product, {foreignKey: 'product_id'})

Git bash错误

throw new Error(this.name + '.hasMany called with something that\'s not asubclass of Sequelize.Model');
  ^

Error: Theme.hasMany called with something that's not a subclass of Sequelize.Model

谢谢!

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。

这是我的方式mini-shop