find one and update sequelize code example

Example 1: sequelize update sql

const Tokens = db.define('tokens', {
    token: {
        type: sequelize.STRING
    }
});
// Update tokens table where id
Tokens.update(
          { token: 'new token' },
          { where: {id: idVar} }
     ).then(tokens => {
          console.log(tokens);
     }).catch(err => console.log('error: ' + err));

Example 2: sequelize update

var Book = db.define(‘books’, {
 title: {
   type: Sequelize.STRING
 },
 pages: {
   type: Sequelize.INTEGER
 }
})

Book.update(
   {title: req.body.title},
   {where: req.params.bookId}
 )

Example 3: update column with find sequelize

Project.find({ where: { title: 'aProject' } })
  .on('success', function (project) {
    // Check if record exists in db
    if (project) {
      project.update({
        title: 'a very different title now'
      })
      .success(function () {})
    }
  })