diff options
author | Mateja <mail@matejamaric.com> | 2021-05-03 17:44:38 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-05-03 17:44:38 +0200 |
commit | 34b3fefaddd165b649c53e140f6b749c18943d26 (patch) | |
tree | 3c53c59d29df1fc1d3165eddd7c83ed3aab871f1 /controllers | |
parent | 9eeca255cfe41ca4a962422c3703274caa530021 (diff) | |
download | node-playground-34b3fefaddd165b649c53e140f6b749c18943d26.tar.gz node-playground-34b3fefaddd165b649c53e140f6b749c18943d26.zip |
Add delete option on every post.
Diffstat (limited to 'controllers')
-rw-r--r-- | controllers/post.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/controllers/post.js b/controllers/post.js index 7c66dec..d879fcc 100644 --- a/controllers/post.js +++ b/controllers/post.js @@ -25,6 +25,10 @@ module.exports = { 'text': req.body.text }); newPost.save().then(() => res.redirect('/')); + }, + + destroy(req, res) { + Post.findByIdAndRemove(req.params.id).then(() => res.redirect('/')); } }; |