I tried to put a custom condition on included model's column to be equal to value of parent model column but it is not working as expected in sequelize 3.8.7 module. Below is the code i tried
Quotes.findOne({
where: {'id' : req.body.quoteId},
include : [
{model : Jobs},
{model : HaulerProfiles, include : [{model : UserFavouriteBanned, where : {'userId' : mysqlORM.sequelize.col('Job.customerId'), 'actionOn' : mysqlORM.sequelize.col('HaulerProfile.id'), 'actionType' : 'B'}, required : false}]}
]
})
But when i check executed query conditions are not included with mysqlORM.sequelize.col. It execute LEFT OUTER JOIN Like this
LEFT OUTER JOIN `UserFavouriteBanned` AS `HaulerProfile.UserFavouriteBanned` ON `HaulerProfile`.`id` = `HaulerProfile.UserFavouriteBanned`.`actionOn` AND `Job`.`customerId` AND `HaulerProfile`.`id` AND `HaulerProfile.UserFavouriteBanned`.`actionType` = 'B'
Please help so i can put conditions on column value of included model.