To use an include with attributes with Node Sequelize, we set the attribute
property.
For instance, we write
Payment.findAll({
where: {
DairyId: req.query.dairyid,
},
attributes: {
exclude: ["createdAt", "updatedAt"],
},
include: {
model: Customer,
attributes: ["customerName", "phoneNumber"],
},
});
to call findAll
to add the attributes
property to exclude.
And we add include
with the columns of Customer
to include.