Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
In this video we'll retrieve single and multiple rows of data from tables.
Important Notice About the findById()
Method
Since the recording of this workshop, the Sequelize findById()
method has been deprecated and replaced by the findByPk()
method.
Using the findByPk()
method, the code for the route to get an individual article looks like this:
/* GET individual article. */
router.get('/:id', function(req, res, next) {
Article.findByPk(req.params.id).then((article) => {
res.render('articles/show', { article: article, title: article.title });
});
});
Sequelize Methods
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up