Reputation: 63
I have a issue in query, When we pass where condition in (include section) of find all.
My code is
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"});
});
It works well if any row present in BookingFeedbackMaster with the status 1 else it gives me no output.
I need to get the other data. No meter if i don't get the BookingFeedbackMaster data. if the condition not match.
Please help someone.
Thanks in advance.
Upvotes: 1
Views: 160
Reputation:
Query the BookingFeedbackMaster
with required: false
. That way, you're performing a left outer join rather than inner join
Upvotes: 2