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.