Sometimes, we want to update record, and return result with Sequelize and JavaScript.
In this article, we’ll look at how to update record, and return result with Sequelize and JavaScript.
How to update record, and return result with Sequelize and JavaScript?
To update record, and return result with Sequelize and JavaScript, we can use the db.connections.update
method.
For instance, we write
const result = await db.connections.update(
{
user: data.username,
chatroomID: data.chatroomID,
},
{
where: { socketID: socket.id },
returning: true,
plain: true,
}
);
to call db.connection.update
to update the user
and chatroomID
values.
We set returning
to true
to return the updated entry as an object with the promise returned by update
.
Conclusion
To update record, and return result with Sequelize and JavaScript, we can use the db.connections.update
method.