select for update sequelize code example
Example 1: sequelize update sql
const Tokens = db.define('tokens', {
token: {
type: sequelize.STRING
}
});
Tokens.update(
{ token: 'new token' },
{ where: {id: idVar} }
).then(tokens => {
console.log(tokens);
}).catch(err => console.log('error: ' + err));
Example 2: update data in sequelize
const objectToUpdate = {
title: 'Hello World',
description: 'Hello World'
}
models.Locale.findAll({ where: { title: 'Hello World'}}).then((result) => {
if(result){
result[0].set(objectToUpdate);
result[0].save();
}
})