diff --git a/app/models/todo.js b/app/models/todo.js index 770f42a6f..b74549ee0 100644 --- a/app/models/todo.js +++ b/app/models/todo.js @@ -4,5 +4,9 @@ module.exports = mongoose.model('Todo', { text: { type: String, default: '' + }, + done: { + type: Boolean, + default: false } -}); \ No newline at end of file +}); diff --git a/app/routes.js b/app/routes.js index b78dbe4fa..36fe9e17a 100644 --- a/app/routes.js +++ b/app/routes.js @@ -5,10 +5,10 @@ function getTodos(res) { // if there is an error retrieving, send the error. nothing after res.send(err) will execute if (err) { + console.error('err :',err); res.send(err); - } - - res.json(todos); // return all todos in JSON format + } else + res.json(todos); // return all todos in JSON format }); }; @@ -29,11 +29,12 @@ module.exports = function (app) { text: req.body.text, done: false }, function (err, todo) { - if (err) + if (err) { + console.error('err :',err); res.send(err); - - // get and return all the todos after you create another - getTodos(res); + } else + // get and return all the todos after you create another + getTodos(res); }); }); @@ -43,10 +44,11 @@ module.exports = function (app) { Todo.remove({ _id: req.params.todo_id }, function (err, todo) { - if (err) + if (err) { + console.error('err :',err); res.send(err); - - getTodos(res); + } else + getTodos(res); }); }); diff --git a/config/database.js b/config/database.js.example similarity index 100% rename from config/database.js rename to config/database.js.example diff --git a/package.json b/package.json index fde172c12..29c1ff2bf 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "author": "Scotch", "dependencies": { "body-parser": "^1.18.2", - "mongoose": "4.10.8", - "express": "^4.10.8", + "mongoose": "6.10.0", + "express": "^4.17.3", "method-override": "^2.3.10", "morgan": "^1.9.0" }