Gary Sieling

Sequelize Update example

There are a couple ways to update values in the Sequelize ORM:

db.Alert.update(
  { url: url },
  { 
    fields: ['url'],
    where: {id: id}
  }
);

If you have an object, this is also supposed to work:

var alert = 
  db.Alert.find(
    {where: {
      id: id,
      UserId: req.user.id
    }});

alert.update({
  url: 'https://www.garysieling.com/blog'
}).then(function() {})
Exit mobile version