Oliver Watkins Oliver Watkins - 1 month ago 6
Node.js Question

How to update a whole record in sequelize (not just single field)

I know how to update a particular field in sequalize

Project.update(
{
title: 'a new value'
},
{
where: {id: 1}
})
.success(function () {
})
.error(function () {
}
);


However, I would like to update a whole row of values/fields.

{
"field1":"foo",
"field2":"bar",
"field3":"bar2"
}


The documentation on the website is not very clear :
http://docs.sequelizejs.com/en/latest/api/model/

Answer

Just pass an object with new data as first parameter to update function

Project.update(
{
    title: 'a new value',
    field1: "foo",
    field2: "bar"
},
{
    where: {id: 1}
})
Comments