how can I findAll orders with id: 1 and include items only if this item has active = true? Otherwise there will be empty array...
Order.findAll({
where: { id: 1 },
include: [
{ model: Item, where: sequelize.and({'active' : true }) }
]
}).then(function(order) {
callback(null, order);
});
This shows me only orders where are some items with active = true. I wanted to show all orders with id: 1 and items as a sub-array ...
From Sequelize Tutorial:
The solution is this: