Relations:
Shop.hasMany(ShopAd, {foreignKey : \'shop_id\', as : \'ads\'});
ShopAd.belongsTo(Shop, {foreignKey : \'id\'})
I using :
required: true
forces anINNER JOIN
, userequired: false
to force aLEFT JOIN
.
Taken from here.
using:
required:false
sentences:
Shop.findAll({
where:{id:shopId},
include:[
{ model:ShopAd, as:'ads',
where:{
is_valid:1,
is_vertify:1},
required:false
}
]
})
.success(function(result) {
callback(result);
});