From 0c3366ac351b5a215c5ad7aceb8977ea7ab9d9a9 Mon Sep 17 00:00:00 2001 From: BrennaManning Date: Thu, 30 Mar 2017 20:09:14 -0400 Subject: [PATCH] catapp with mongoose feedback --- homework3/feedback.txt | 26 ++++++++++++++++++++++++++ homework3/models/catModel.js | 2 +- homework3/routes/index.js | 8 ++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 homework3/feedback.txt diff --git a/homework3/feedback.txt b/homework3/feedback.txt new file mode 100644 index 00000000..90d8abe5 --- /dev/null +++ b/homework3/feedback.txt @@ -0,0 +1,26 @@ +Homework Feedback for Cat App with Mongoose: + +Functionality: + +All of the required features work! +The createToy function does not work because toys is a property of each cat within allCats, +not a property of allCats. If you want to try out embedding again, you will probably know how to do this now! Nice job trying out an additional/challenging feature. Your advanced query was functional. + +The only bugs were in the additional challenges portion of the assignment, so you will not lose any points for those. + +Completion: (20/20) +Bug Free: (10/10) + +Quality: + +You followed good coding practices throughout! Your code was very readable. +It looks like you forgot to put a comment explaining what the gteCat function does, and spacing could be a little more consistent. + +Good Coding Practices: (10/10) +Readability: (9/10) + + +Summary: +Nice work! Your advanced query worked and it was awesome to start trying out something more challenging. You had a great handle on how to integrate the mongo database! + +(49/50) \ No newline at end of file diff --git a/homework3/models/catModel.js b/homework3/models/catModel.js index f3dedbbc..8cc9ac42 100644 --- a/homework3/models/catModel.js +++ b/homework3/models/catModel.js @@ -1,4 +1,4 @@ -// getting-started.js +// getting-started.js <- Is this leftover from a boiler plate? var mongoose = require('mongoose'); var Toy = require('../models/toyModel.js'); mongoose.connect('mongodb://localhost/cats'); diff --git a/homework3/routes/index.js b/homework3/routes/index.js index 363884a9..71be2c84 100644 --- a/homework3/routes/index.js +++ b/homework3/routes/index.js @@ -31,6 +31,11 @@ function randColors(array){ var createToy = function (req,res){ Cat.find({}, function(err,allCats){ var myToy = new Toy({name:rand(catToys)}); + + // The reason that this does not work is that toys is a property of each cat in allCats + // not a property of allCats. If you print allCats you can see that it's a list of cats. + // Because of this allCats.toys does not exist and going to the /newtoy route makes the app crash. + // Awesome to work towards implementing this additional feature though. allCats.toys.push(myToy); allCats.save(); console.log(allCats) @@ -97,6 +102,9 @@ var deleteCat = function (req,res){ }); } + +// Would be nice to add a comment here explaining what this function is for! +// It is functional though! Nice use of an advanced query here. var gteCat = function (req,res){ Cat.find({age: {$gte: 7}}, function(err, allCats){ res.render("cats",{"classes": allCats})