1const Tokens = db.define('tokens', {
2 token: {
3 type: sequelize.STRING
4 }
5});
6// Update tokens table where id
7Tokens.update(
8 { token: 'new token' },
9 { where: {id: idVar} }
10 ).then(tokens => {
11 console.log(tokens);
12 }).catch(err => console.log('error: ' + err));
1
2const objectToUpdate = {
3title: 'Hello World',
4description: 'Hello World'
5}
6
7models.Locale.findAll({ where: { title: 'Hello World'}}).then((result) => {
8 if(result){
9 // Result is array because we have used findAll. We can use findOne as well if you want one row and update that.
10 result[0].set(objectToUpdate);
11 result[0].save(); // This is a promise
12}
13})
14
1Project.find({ where: { title: 'aProject' } })
2 .on('success', function (project) {
3 // Check if record exists in db
4 if (project) {
5 project.update({
6 title: 'a very different title now'
7 })
8 .success(function () {})
9 }
10 })