inner join in 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: left join in sequelize
Shop.findAll({
where:{id:shopId},
include:[
{ model:ShopAd, as:'ads',
where:{
is_valid:1,
is_vertify:1},
required:false
}
]
})
.success(function(result) {
callback(result);
});
Example 3: sequelize left join attributes
Users.findAll({
include: [
{
model: Role,
as: 'roles',
attributes: ['columnNameToInclude']
}
]
});