Skip to content

Instantly share code, notes, and snippets.

View germanruzca's full-sized avatar
🚀
Learning

German Ruiz germanruzca

🚀
Learning
View GitHub Profile
@zcaceres
zcaceres / Returning-in-Sequelize.md
Last active June 6, 2024 07:21
Using `Returning` with Sequelize and Postgres

Using Returning with Sequelize and Postgres

Some Sequelize commands don't return anything (or at least not anything useful) by default. Sequelize uses an option called returning to specify which data returns from a commands like .destroy() or update().

Let's look at three common Sequelize commands and see how to handle the data returned by each.

Create

By default, .create() returns the newly created instance. This is convenient, because we can then send data to the user: