将间接关联关联起来

我有3个表名为项目,工作区,视图和关联

projects.hasMany(workspace); workspace.belongsTo(projects); workspace.hasMany(views); views.belongsTo(workspace); 

我需要连接这三个表来获得以下查询的输出

 select * from projects pro join workspace wrk on pro.id= wrk.project_id join views on wrk.id = views.workspace_id 

我试过一个关联

 views.belongsTo(projects, { through: workspace.associations.projects }); 

以下是代码:

 View.findAll({ include: [ {model: db.workspaces, required: true}, {model: db.projects, required: true} ] }); 

但它会生成查询

 SELECT * FROM "views" AS "views" INNER JOIN "workspaces" AS "workspace" ON "views"."workspace_id" = "workspace"."id" INNER JOIN "projects" AS "project" ON "views"."project_id" = "project"."id" 

视图表中不存在project_id,只能通过workspace关联视图,如何实现。

       

网上收集的解决方案 "将间接关联关联起来"