Consider the code:
const listOfEmployees = .... // get list of employees from god knows where ...
async function incrementHoursEmps(listOfEmployees) {
listOfEmployees.map(async employeeId => {
const condition = { where : {employeeId} };
const options = { multi: true };
const values = { hoursWork: sequelize.literal('"hoursWork" + 1') };
ModelEmployees.update(values, condition , options)
.then(result => {
// ....
})
.catch(error => {
console.log(error);
});
});
}
await incrementHoursEmps(listOfEmployees);
Whenever I try to update multiple rows (or even just a single row) using the .update()
method of Sequelize
, the code never awaits and the .update()
doesn't really update.
Is it even working or am I doing something wrong ?