Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sequelize.js 嵌套和续集_Sequelize.js - Fatal编程技术网

Sequelize.js 嵌套和续集

Sequelize.js 嵌套和续集,sequelize.js,Sequelize.js,我有一个预订表,我只想恢复coach的所有预订,但在特定日期,状态为(boolean=true) 在我的预订表中,我有一位教练,他只预订了座位,但这个请求也让我知道了其他教练的时间 我的请求: Booking.findAll({ attributes: ['booked_time'], where: { fk_id_coach: coachId, [Op.and]: {

我有一个预订表,我只想恢复coach的所有预订,但在特定日期,状态为(boolean=true)

在我的预订表中,我有一位教练,他只预订了座位,但这个请求也让我知道了其他教练的时间

我的请求:

 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