Reputation: 13787
I want to update all records meet our criteria with updateAttributes
in postgres sequelize.
deactivateJobsByCompany(companyData.id, {transaction: t}).then(function(jobs) {
jobs.updateAttributes({is_active: false}, {transaction: t}).then(function () {
onSuccess(company);
})
});
I don't know why jobs.updateAttributes
got error. Please let me know how to solve it. Thanks.
Upvotes: 0
Views: 5218
Reputation: 3622
You can use the update method, something like
Model.jobs.update({is_active:false},
{where:{company_id:Id}})
Also updateAttributes works on an model instance, is the jobs
returned by
deactivateJobsByCompany
a model instance
If it returns an array of jobs, you might need to call updateAttributes
on each of them.
Upvotes: 1