How to implement many to many association in sequelize

前端 未结 4 667
庸人自扰
庸人自扰 2020-11-27 09:33

I have two tables: Books and Articles with a many-to-many relationship between them. Joining table is BookArticles.

models/books.js

module.exports =          


        
4条回答
  •  孤城傲影
    2020-11-27 10:00

    M:M relation through table BookArticles:

    m.Book.belongsToMany(m.Article, {through: m.BookArticles});
    m.Article.belongsToMany(m.Books, {through: m.BookArticles});
    

提交回复
热议问题