Sunday 21 May 2017

Sequelize increment function returning error

Trying to increment an integer field on a model instance in my DB. Here is the relevant code.

models.Options.findAll({
        where: { 
            PollId: poll_id, 
            name: option_to_update
        }
    }).then((option) => {
        option.increment('votes');
        res.json(option);
    });

When I console.log(option), it shows as an Instance so I know it inherits from the Instance class which has an increment function as can be seen here

https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L934

Not really sure what I'm doing wrong.



via Zaid Humayun

No comments:

Post a Comment