Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In sequelize updateattributes method can update only one attribute in a table?

I tried(sequelize model) to update the values in the table, but it will update the only one value in the table.check the below example

employee.updateAttributes({first_name : value.first_name},
            {last_name : value.last_name},
            {email : value.email},
            {password : value.password},
            {phone : value.phone}
            ).on('success',function(employee){
    message.message = "Employee updated successfully";
    message.employee = employee;
    message.successMessage = "Success";
    callback(message);
})
like image 378
Sarath Kumar Avatar asked Dec 09 '22 06:12

Sarath Kumar


2 Answers

You should provide a single object

employee.updateAttributes({
  first_name : value.first_name,
  last_name : value.last_name,
  email : value.email,
  password : value.password,
  phone : value.phone
})
like image 150
Jan Aagaard Meier Avatar answered Dec 29 '22 01:12

Jan Aagaard Meier


use .update() in lieu of .updateAttributes()

like image 35
buycanna.io Avatar answered Dec 29 '22 00:12

buycanna.io