DEV Community 👩‍💻👨‍💻

Tiamiyu Sikiru Abidemi
Tiamiyu Sikiru Abidemi

Posted on • Updated on

Sequelize Model.update

Using sequelize for model creation, i needed to update my database so i used Model.findByIdAndUpdate which returned an error and i later found the right way to update to the database using
Model.update({
title: 'Updated title '
},
{
where:
{
id: 1
}
})
I hope this helps someone out there... or is their any other way ? i will like to know thanks.
example below:
https://thepracticaldev.s3.amazonaws.com/i/xv3dnnshqqitd1gs9k66.png

Top comments (5)

Collapse
leirasanchez profile image
Leira Sánchez

Do you know if it's possible to update multiple fields at once using this method?

thank you

Collapse
abidemit profile image
Tiamiyu Sikiru Abidemi Author

Sorry I got your comment late, were you able to resolve this?

Collapse
leirasanchez profile image
Leira Sánchez

Yes! I don't remember what I was doing wrong. It was something silly. Thank you for replying!

Collapse
bebetter12 profile image
bebetter12

Thanks man!

Collapse
md_salehzadeh profile image
Mohammad Salehzadeh

Thanks a lot, they were hiding the solution in their docs.

🌚 Friends don't let friends browse without dark mode.

Good news! You can update to dark mode in your DEV settings.