'Sequelize can update data with !value, but fails to update with boolean value
I recently started learning MySQL and get a little problem.
First:
words.findByPk(req.params.id)
.then(word => {
return word.update({
test: !word.dataValues.test
})
})
Second:
words.findByPk(req.params.id)
.then(word => {
word.dataValues.test
? word.dataValues.test = false
: word.dataValues.test = true
return word.update({
test: word.dataValues.test
})
})
I don't know why the first way works to update the repository and the second fails. Using "console.log" results are true or false.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
