include sequelize code example
Example 1: sequelize include only
Payment.findAll({
where: {
DairyId: req.query.dairyid
},
attributes: {
exclude: ['createdAt', 'updatedAt']
},
include: {
model: Customer,
attributes:['customerName', 'phoneNumber']
}
})
Example 2: nested include sequelize
models.products.findAll({
include: [
{model: models.comments, include: [models.comments.users] }
]
})
Example 3: in in sequelize
await Tag.findAll({
where: {
id: {
[Sequelize.Op.in]: [1, 2, 3, 4]
}
}
});
Example 4: sequelize include twice
Test.findAll({
include: [
{ model: Model1 },
{ model: Model2 }
]
});