如何添加日志以进行序列更新 [英] How to add logging for sequelize update

查看:69
本文介绍了如何添加日志以进行序列更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目sequelize中,日志记录已禁用,但我希望在准确的查询中进行主动日志记录.

In my project sequelize logging is disabled, but I want active logging in the exact query.

我该怎么做?

TableModel.update(
    {counter: 0},
    {where: {
        id: itm.i
    }},
    ).then((res) =>{
        console.log('res',res);
    }).catch(e => {
        console.log('update error : ', e);
    });

我知道如何在findall查询中做到这一点:

I know how I can do it in findall query like this:

TableModel.findAll({where: {...}, logging: console.log})

但是在更新中,我找不到任何解决方案.

but in the update, I can't find any solution.

后续版本:5.21

推荐答案

我找到了解决方法.

那很容易,只需在选项中添加logging:true.

that was so easy just adding logging:true in options.

TableModel.update(
    {counter: 0},
    {
        where: {
            id: itm.i
        },
        logging:true
    }
    ).then((res) =>{
        console.log('res',res);
    }).catch(e => {
        console.log('update error : ', e);
    });

这篇关于如何添加日志以进行序列更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆