Shop.findAll({
where:{id:shopId},
include:[
{ model:ShopAd, as:'ads',
where:{
is_valid:1,
is_vertify:1},
required:false
}
]
})
.success(function(result) {
callback(result);
});
Users.findAll({
include: [
{
model: Role,
as: 'roles',
attributes: ['columnNameToInclude']
}
]
});
User.hasMany(Post, {foreignKey: 'user_id'})
Post.belongsTo(User, {foreignKey: 'user_id'})
Post.find({ where: { ...}, include: [User]})
Posts.findAll({
include: [{
model: User,
required: true
}]
}).then(posts => {
/* ... */
});