续集关联问题

我在查询中有一个问题,当我们通过查找所有的(包含段)条件时。

我的代码是

db.Doctor.findAll({ attributes : ['id','firstName','lastName', 'profilePicture','education','experience', 'fees','gender','mobile','email'], include: [ { model : db.Category, attributes : ['title']}, { model : db.Area, attributes : ['name']}, { model : db.City, attributes : ['name']}, { model : db.State, attributes : ['name']}, { model : db.Country, attributes : ['name']}, { model : db.DoctorClinicPicture, attributes : ['imagePath']}, { model : db.BookingFeedbackMaster, attributes : ['rating','comment'], where : { status: 1 } } ], where : { id: req.query.doctorId}, order: 'id ASC' }).then(function(data){ if (data != null ) { res.json({status:true,msg:"Doctor viewed successfully!!",data:data}); } else { res.json({status:true,msg:"Doctor is temporary not available",data:""}); } }).catch(function(err){ res.json({status:"fail"}); }); 

如果在状态为1的情况下在BookingFeedbackMaster中出现任何行,那么效果很好,否则它不会输出任何结果。

我需要得到其他的数据。 没有米,如果我没有得到BookingFeedbackMaster数据。 如果条件不匹配。

请帮助别人。

提前致谢。

使用required: false查询BookingFeedbackMaster required: false 。 这样,你正在执行一个左外连接,而不是内连接