aboutsummaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-05-03 17:44:38 +0200
committerMateja <mail@matejamaric.com>2021-05-03 17:44:38 +0200
commit34b3fefaddd165b649c53e140f6b749c18943d26 (patch)
tree3c53c59d29df1fc1d3165eddd7c83ed3aab871f1 /controllers
parent9eeca255cfe41ca4a962422c3703274caa530021 (diff)
downloadnode-playground-34b3fefaddd165b649c53e140f6b749c18943d26.tar.gz
node-playground-34b3fefaddd165b649c53e140f6b749c18943d26.zip
Add delete option on every post.
Diffstat (limited to 'controllers')
-rw-r--r--controllers/post.js4
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('/'));
}
};