0

I've read the documentation of sequelize quite thoroughly and I can't seem to find any way to perform operations on multiple rows simultaneously. Something like

UPDATE mytable SET expired=1;

The only way I can see of doing this through sequelize would be to run mytable.all() and loop through each resulting row, setting expired to 1 and saving it. This would take the same amount of queries as there are rows in the table (could be thousands) instead of the one simple query.

Does sequelize perhaps have some undocumented method of doing this? Or perhaps just well hidden in the documentation? Is it possible to run custom SQL queries through some undocumented private field of sequelize?

Any info on the subject appreciated

1 Answer 1

1

it is currently not possible to perform an update on multiple rows at once. Nevertheless you can use the query-method of your sequelize instance. I just checked out if it is possible and, yeah, it is. Like this:

sequelize.query('UPDATE mytable SET expired=1')

Have phun!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.