Sequelize 事务阻止更新行

Sequelize transaction prevent updating row

当我在更新查询中使用事务时,它会阻止更新行。这是我所做的:

let t = await sequelize.transaction();
let updated = User.update({
    lastName: 'new lastname',
    firstName: 'new firstname'
}, 
{
where: { email:'zzz@yyy.com' },
// doesn't update with transaction
// transaction: t
})
.then(success(res))

顺便说一句,它更新了数据库中的 updatedAt 列,但其他字段仍然相同。有什么想法吗?

更新: 当我 运行 在其他函数中进行一些查询并将 t(交易)传递给该函数时,就会发生这种情况。

像这样尝试我认为这会在这里工作我正在使用 async await 而不是基于承诺的方法。我使用的交易是Managed transactions如果你想在你的应用程序中使用交易最好使用

updateUser: async (req, res) => {
    sequelize.sequelize.transaction(async (t1) => {

        let data = await User.findOne({
            where: {
                id: req.body.id
            }
        });
        if (data) {
            await User.update(req.body, { where: { id: req.body.id } });
            return res.status(200).send(error.OK);
        }
        else {
            return res.status(422).send(error.DATA_NOT_FOUND);
        }
    }).catch(function (err) {
        console.log(err)
        return res.status(500).send(error.SERVER_ERROR);
    });
}