How can I execute this query in sequelize
P粉354602955
2023-09-05 09:43:31
<p><pre class="brush:php;toolbar:false;">SELECT *
FROM item_master
WHERE project_id IN (SELECT id FROM project_master
WHERE workspace_id in (SELECT id FROM workspace_master
WHERE company_id = 4));</pre>
<p>How to execute this mysql query in sequelize - Node js without using original query? </p>
If your model structure is like
item_master
has manyproject_master
, andproject_master
has manyworkspace_master
, then the following sequelize query will Applied together withasync/await
.As I edit my answer. As you said in your comments you have model structure like workspace has many projects and project has many projects. Then the Sequelize query will look like:
Try it now, I hope this solves your problem.
This is working the way I want.