Tuesday 7 November 2017

Sequelize help needed

Hi! I'm new to Sequelize, and I am trying to join a table on a subquery, but I don't know how to express it using Sequelize ORM. This is the raw SQL I want to run:SELECT * FROM table_a a LEFT OUTER JOIN (SELECT * FROM table_b b WHERE col = VAL) ON a.id = b.id;I triedA.findAll({include: [ { model: B, where: { col: val }, } ] }).then(...);but that doesn't get me the query I want. Instead it changes the join to an INNER JOIN, and joins on col = VALUE instead of inside a subquery. Is there a way to do a join on the result of a subquery? I am using Postgres if it matters.

Submitted November 07, 2017 at 10:22PM by andynaguyen

No comments:

Post a Comment