1
我在查詢中有一個問題,當我們通過查找所有條件(包含段)的時候。續集關聯問題
我的代碼是
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"});
});
它運作良好,如果出現在BookingFeedbackMaster任何行與狀態1,否則它給了我無輸出。
我需要獲取其他數據。沒有米,如果我沒有得到BookingFeedbackMaster數據。如果條件不匹配。
請幫助別人。
在此先感謝。
是的,它的工作表示感謝。現在我必須做如查詢,即:區域以'abc'開始或以'abc'開始。有沒有辦法做到這一點?所以,我可以在數據表jQuery插件中使用它。 – divyang
是的。例如,要查詢以'abc'開頭的名稱,請使用'name:{$ like:'abc%'}' – 2016-04-28 06:12:47
實際上,我有一個搜索框並需要將其與所有字段匹配。 Doctor表格的名字,Category表格的標題等等。請幫幫我。 – divyang