how sequelize.addHook(“afterUpdate”) work?

i’m new in node.js and sequelize ORM, as you guys can see below of my description was the function update and addHook for my database and if the function update already execute i want the addhook add some logic, but here’s the bug i got
Executing (default): UPDATE 'testings' SET 'BulNormal'=? WHERE 'id' = ?, the notification executing update from my console was success but the addHook function is not run. i wonder why is this happening ? do anyone have some solution ?

const testeasy = async(req,res) =>{
    try {

        try {
            await testing.update({BulEasy : totalSum},{
                where : {id:idStudent},
            })   
            return res.status(200).json("Data is created")   
        } catch (error) {
            console.log(error)
            return res.status(503).json("error")
        }
    } catch (error) {
        console.log(error)
    }
}

testing.addHook("afterUpdate", async (data, res) => {
    try {
        console.log("afterupdate work");
    } catch (e) {
        console.log(e);
    }
});

Leave a Comment