Sequelize.js 嵌套和续集
我有一个预订表,我只想恢复coach的所有预订,但在特定日期,状态为(boolean=true) 在我的预订表中,我有一位教练,他只预订了座位,但这个请求也让我知道了其他教练的时间 我的请求:Sequelize.js 嵌套和续集,sequelize.js,Sequelize.js,我有一个预订表,我只想恢复coach的所有预订,但在特定日期,状态为(boolean=true) 在我的预订表中,我有一位教练,他只预订了座位,但这个请求也让我知道了其他教练的时间 我的请求: Booking.findAll({ attributes: ['booked_time'], where: { fk_id_coach: coachId, [Op.and]: {
Booking.findAll({
attributes: ['booked_time'],
where: {
fk_id_coach: coachId,
[Op.and]: {
booked_date: fullDate,
[Op.and]: {
status: true
}
}
}
}).then(results => {
return res.json({
results
})
此请求返回每个coach保留的所有时间。。。我只想在一个精确的日期上检查coach的保留时间,并且status=true不需要嵌套和查询,您可以这样做
Booking.findAll({
attributes: ['booked_time'],
where: {
fk_id_coach: coachId,
booked_date: fullDate,
status: true
}
}).then(results => { return res.json({results} )
如果它仍然不起作用,请发布您的原始查询,以便我们能够正确调试它。谢谢@Vivek Doshi,我找到了其他解决方案:
coach.getBookings({
attributes: ['booked_time'],
where: {
booked_date: fullDate,
[Op.and]: {
status: true
}
}
更好的方式与联想,我没有想到这一点
:p