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