I'm trying to write a sequelize function that looks like this SQL code:
SELECT * from events INNER JOIN corrections on events.correctionId
= correction.id WHERE events.failureId = 1234 OR
corrections.failureId = 1234
Basically, I have a table (events) that has a foreign key of failureId and correctionId. The correction table also has a foreign key to failure table. I need all the rows in events where the failureId is equal to a particular AND all the rows where the failureId on the corrections table is equal to that number.
The part I'm having trouble with is referencing that corrections.failureId column that results from that inner join. I've tried a bunch of variations but nothing is working. Here's what I have so far:
Event.findAll({
include: [correction],
where: { [sequelize.Op.or]: [{ failID }, {????}] }