且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

续集多对多连接的位置

更新时间:2022-12-30 18:27:29

使用 Belongs-To-Many,您可以基于直通关系和选择特定属性.例如将 findAll 与 through 一起使用

With Belongs-To-Many you can query based on through relation and select specific attributes. For example using findAll with through

User.findAll({
  include: [{
    model: Project,
      through: {
        attributes: ['createdAt', 'startedAt', 'finishedAt']
          where: {completed: true}
      }
   }] 
 });

基本上你可以使用 through 选项和 include 你链接的关系.更多信息请参见这里

Basically you can use through option and include the relationship that you linked. More can be found here