I have a little question about updating just one attribute and not all like in this code.
router.put("/update/:id", (req, res) => {
const id = req.params.id;
Account.update(req.body, {
where: { id: id },
})
.then((num) => {
if (num == 1) {
res.send({
message: "Informatiile au fost actualizate cu succes.",
});
} else {
res.send({
message: `Nu pot actualiza informatiile pentru contul cu id=${id}.`,
});
}
})
.catch((err) => {
res.status(500).send({
message: "Eroare actualizare date pentru id=" + id,
});
});
});
One register from my database looks like this:
{
name: 'x',
password: 'x',
activated: 0
}
All I want to do is to make that 0 in 1 and I don't know what I have to change in my code because if I use this code, I will update all parameters (name, password, activated) and I want to update just one.