Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

William Mead
William Mead
9,937 Points

Missing where attribute in the options parameter ERROR

I am getting an error when I try to use the update code as seen in the video. Apparently Sequilize has been updated so that the options parameter is not optional. I found this Stack Overflow post, with an answer that links to the updated documentation.

From that post and info in the documentation I was able to work out this change in the code:

router.post('/:id/edit', asyncHandler(async (req, res) => {
  const article = await Article.findByPk(req.params.id);
  const selector = { 
    where: { id: article.id }
  };
  await Article.update(req.body, selector);
  res.redirect("/articles/" + article.id);
}));

Note the selector variable that gets passed into the update method.