1Shop.findAll({
2 where:{id:shopId},
3 include:[
4 { model:ShopAd, as:'ads',
5 where:{
6 is_valid:1,
7 is_vertify:1},
8 required:false
9 }
10 ]
11 })
12 .success(function(result) {
13 callback(result);
14 });
1Posts.findAll({
2 include: [{
3 model: User,
4 required: true
5 }]
6}).then(posts => {
7 /* ... */
8});
9
1Users.findAll({
2 include: [
3 {
4 model: Role,
5 as: 'roles',
6 attributes: ['columnNameToInclude']
7 }
8 ]
9});
1User.hasMany(Post, {foreignKey: 'user_id'})
2Post.belongsTo(User, {foreignKey: 'user_id'})
3
4Post.find({ where: { ...}, include: [User]})
5