Does sequelize create a many-to-many relationship to report an error?

define association:

 Theme.belongsToMany(Product,{through:theme_product,foreignKey:"theme_id"})
 Product.belongsToMany(Theme,{through:theme_product,foreignKey:"product_id"})

theme_product is the intermediate table

error message:

 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
Dec.18,2021
The

problem has been resolved and the two models are not under the same sequelize instance.
refer to this project: https://codeshelper.com/a/11.


Hello, I also encountered this error. How did you solve it? can you share your code in detail?


I realized it in this way. I don't know if it's helpful to you.
Wordbook is the relationship table between word (vocabulary list) and book (material list)
Wordbook.belongsTo (WordModel, {
foreignKey: "wordid",
constraints: false,
});
/ / BelongsTo association indicates that the foreign key of an one-to-many relationship exists in the source model.
Wordbook.belongsTo (BookModel, {
foreignKey: "bookid",
constraints: false,
});

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c57a-2ba83.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c57a-2ba83.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?