From f3d12daefb1d32a01c9a31e86150c51fda0fa9cf Mon Sep 17 00:00:00 2001 From: Aakash Choubey Date: Sat, 30 Sep 2017 03:16:32 +0530 Subject: [PATCH 1/2] Update index.js Some Functions like removeById and updateById were removed from Monk. These changes make the app run fine. PS: Thanks for the awesome series! --- 10-monk/routes/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/10-monk/routes/index.js b/10-monk/routes/index.js index 86de69d..710ae60 100644 --- a/10-monk/routes/index.js +++ b/10-monk/routes/index.js @@ -9,9 +9,8 @@ router.get('/', function(req, res, next) { }); router.get('/get-data', function(req, res, next) { - var data = userData.find({}); - data.on('success', function(docs) { - res.render('index', {items: docs}); + userData.find({}).then((docs) => { + res.render('index',{items: docs}); }); }); @@ -36,14 +35,14 @@ router.post('/update', function(req, res, next) { var id = req.body.id; // userData.update({"_id": db.id(id)}, item); - userData.updateById(id, item); + userData.update(id, item); }); router.post('/delete', function(req, res, next) { var id = req.body.id; // userData.remove({"_id": db.id(id)}); - userData.removeById(id); + userData.remove(id); }); module.exports = router; From 8217e43f18de3b8b62c6afc2904b0babd2dd576a Mon Sep 17 00:00:00 2001 From: Aakash Choubey Date: Sat, 30 Sep 2017 03:40:26 +0530 Subject: [PATCH 2/2] Update index.js --- 10-monk/routes/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/10-monk/routes/index.js b/10-monk/routes/index.js index 710ae60..b56fcb2 100644 --- a/10-monk/routes/index.js +++ b/10-monk/routes/index.js @@ -9,7 +9,8 @@ router.get('/', function(req, res, next) { }); router.get('/get-data', function(req, res, next) { - userData.find({}).then((docs) => { + userData.find({}) + .then(function(docs){ res.render('index',{items: docs}); }); });