【问题标题】:how to check that record updated or not using sequelize如何使用 sequelize 检查记录是否更新
【发布时间】:2021-12-11 00:08:27
【问题描述】:

在这段代码中,我更新了一个模型的记录 IPAdress.

我现在如何检查记录是否已更新。

let IPAdress = await model.IPAdress.update(data,{ where: { id } });

【问题讨论】:

    标签: javascript node.js express sequelize.js


    【解决方案1】:
    if index 0 of an array is 0 then it mean that record has not updtaed yet.
    let IPAdress = await model.IPAdress.update(data,{ where: { id } });
    if(IPAdress[0] == 0) throw "Error Message";
    else { print("record has been updated ");
    

    【讨论】:

    • 非常感谢它的工作。我测试了无效的演示数据,它抛出了一个错误。
    猜你喜欢
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    • 2018-06-02
    • 2023-04-08
    • 1970-01-01
    • 2012-02-14
    • 2012-06-11
    • 1970-01-01
    相关资源
    最近更新 更多