Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Commit e1fa2c4

Browse files
committed
Use findByPk
1 parent c6db5ec commit e1fa2c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

backend/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ app.post('/sites', (req, res) => {
5959
});
6060

6161
app.put('/sites/:id/:action(upvote|downvote)', (req, res) => {
62-
models.Site.findOne({where: {id: req.params.id}}).then(site => {
62+
models.Site.findByPk(req.params.id).then(site => {
6363
return site.increment(`${req.params.action}s`, {by: 1});
6464
}).then(site => {
6565
res.status(200).json({});
@@ -70,7 +70,7 @@ app.put('/sites/:id/:action(upvote|downvote)', (req, res) => {
7070
});
7171

7272
app.put('/sites/:id/:action(upvote|downvote)/revert', (req, res) => {
73-
models.Site.findOne({where: {id: req.params.id}}).then(site => {
73+
models.Site.findByPk(req.params.id).then(site => {
7474
return site.decrement(`${req.params.action}s`, {by: 1});
7575
}).then(site => {
7676
res.status(200).json({});

0 commit comments

Comments
 (0)