Mysql
 SQL >> Base de Dados >  >> RDS >> Mysql

Como atualizar um registro usando Sequelize no Node

A partir da versão 2.0.0, a cláusula where precisa estar dentro de where:

Project.update(
  { title: 'Novo título' },
  { where: { _id: 1 } }
)
.then(result => handleResult(result))
.catch(err => handleError(err));

Com async/await:

try {
  const result = await Project.update(
    { title: 'Novo título' },
    { where: { _id: 1 } }
  );
  handleResult(result);
} catch (err) {
  handleError(err);
}