Node.js 续集事务未正确返回承诺链的结果

Node.js 续集事务未正确返回承诺链的结果,node.js,sequelize.js,Node.js,Sequelize.js,我正在运行nodeJS和Sequelize(使用MSSQL),并且正在使用一个如下所示的事务: app.post('/getOne', ({body}, res) => { return sequelize.transaction(t => { return getOneStudent(body.id, {transaction: t}) .then(student => { if (student != null

我正在运行nodeJS和Sequelize(使用MSSQL),并且正在使用一个如下所示的事务:

app.post('/getOne', ({body}, res) => {
    return sequelize.transaction(t => {
        return getOneStudent(body.id, {transaction: t})
        .then(student => {
            if (student != null){
                return getStudentsGuardians(student.id, {transaction: t})
            }
        })
        .catch(error => {throw new Error(error)})
    })
    .then(result => res.status(200).send({
        studentValues: result,
        success: true,
        })
    )
    .catch(error => res.status(400).send({
        response: error,
        success: false
    }))
})
函数
getOneStudent
getStudentsGuardians
都是返回承诺的续集函数

第一个应该从数据库返回student对象,后者应该返回学生监护人ID的json列表。。。无论出于什么原因,它都会返回这个:

{
    "studentValues": [
        [
            {
                "user_id": 1
            },
            {
                "user_id": 2
            }
        ],
        [
            {
                "user_id": 1
            },
            {
                "user_id": 2
            }
        ]
    ],
    "success": true
}
以下是getOneStudent和GetStudentsGuardian:

function getOneStudent(id) {
    return models.Student.findByPk(id)
}

function getStudentsGuardians(id){
    return sequelize.query('SELECT user_id FROM Guardians WHERE student_id = ' + id)
}

如果我删除任何一条return语句,它仍然会成功:true但没有studentValues。你知道为什么我不能从getOneStudent获取返回值以在承诺链中解析吗?

getOneStudent和getStudentsGuardians看起来像什么吗?这个问题的答案是: