{"id":2833,"date":"2015-12-29T18:51:16","date_gmt":"2015-12-29T18:51:16","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=2833"},"modified":"2015-12-29T18:51:16","modified_gmt":"2015-12-29T18:51:16","slug":"sequelize-update-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/sequelize-update-example\/","title":{"rendered":"Sequelize Update example"},"content":{"rendered":"<p>There are a couple ways to update values in the Sequelize ORM:<\/p>\n<pre lang=\"javascript\">\ndb.Alert.update(\n  { url: url },\n  { \n    fields: ['url'],\n    where: {id: id}\n  }\n);\n<\/pre>\n<p>If you have an object, this is also supposed to work:<\/p>\n<pre lang=\"javascript\">\nvar alert = \n  db.Alert.find(\n    {where: {\n      id: id,\n      UserId: req.user.id\n    }});\n\nalert.update({\n  url: 'https:\/\/www.garysieling.com\/blog'\n}).then(function() {})\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are a couple ways to update values in the Sequelize ORM: db.Alert.update( { url: url }, { fields: [&#8216;url&#8217;], where: {id: id} } ); If you have an object, this is also supposed to work: var alert = db.Alert.find( {where: { id: id, UserId: req.user.id }}); alert.update({ url: &#8216;https:\/\/www.garysieling.com\/blog&#8217; }).then(function() {})<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[13],"tags":[302,315,387,389,412,437,504],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2833"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=2833"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/2833\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=2833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=2833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=2833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}