续集关联问题
我在查询中有一个问题,当我们通过查找所有的(包含段)条件时。
我的代码是
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
。 这样,你正在执行一个左外连接,而不是内连接
- 为什么具有真正Headless选项的Chrome 59-Beta无法使用量angular器?
- 如何在Angular 4 / expressJS服务器上直接运行项目(没有webpack)
- 如何获得一个NodeJS转换stream为每个input块发出多个logging?
- Node.js是应用程序不侦听指定的端口
- Nodejsexpression本地和Facebook的集成authentication
- 如何完全删除一个nodejs模块的所有function,甚至包括setInterval?
- 下载并修剪aerospike udf列表
- Jade无法读取每个循环中未定义的属性“长度”
- 使用Npm.depends声明testing依赖关系