Sequelize Model.update
Tiamiyu Sikiru Abidemi

Tiamiyu Sikiru Abidemi @abidemit

About: Javascript Frontend Developer and GDG Ibadan Organizer

Location:
Ibadan, Oyo State, Nigeria
Joined:
Jan 28, 2019

Sequelize Model.update

Publish Date: Feb 10 '19
4 5

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

Comments 5 total

  • bebetter12
    bebetter12Oct 31, 2019

    Thanks man!

  • Mohammad Salehzadeh
    Mohammad SalehzadehMay 13, 2020

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

  • Leira Sánchez
    Leira SánchezJul 10, 2020

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

    thank you

    • Tiamiyu Sikiru Abidemi
      Tiamiyu Sikiru AbidemiAug 5, 2020

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

      • Leira Sánchez
        Leira SánchezAug 12, 2020

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

Add comment