Join on a joined model

27 Views Asked by At

I'm using sequelize as an ORM with a postreSQL database. Simple joins are quite easy to use with the include attribute, but what if I need to join a model from one that was also joined? I tried to add an include attribute in the first one, but it did not work.

Is there a standard way to achieve this?

1

There are 1 best solutions below

0
Jan Aagaard Meier On

Adding a nested include should be the way to do it:

Model.findAll({ include: { model: SomeModel, include: [ SomeOtherModel ]}})

Perhaps you are using an old version - it was introduced late in 2.0 I think