Is it possible to perform a nested include in Sequelize? I have a table called products that has a one-to-many relationship with comments, and the comments table has a many-to-one relationship with the users table. Each comment has a user_id and product_id associated with it. My current code looks like this:
var models = require('../models');
models.products.findAll({
include: [
{model: models.comments}
]
}).then(function (products) {
next(products);
}).catch(function (err) {
next(err);
});
});
I am able to retrieve the comments successfully, but what I really want is something like this:
models.products.findAll({
include: [
{model: models.comments.include(models.comments.users)}
]
})
Is there a way to achieve this without having to write custom queries?