summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--week-7/Final4/blog/package.json2
-rw-r--r--week-7/Final4/blog/posts.js10
2 files changed, 10 insertions, 2 deletions
diff --git a/week-7/Final4/blog/package.json b/week-7/Final4/blog/package.json
index 093690d..bdec04a 100644
--- a/week-7/Final4/blog/package.json
+++ b/week-7/Final4/blog/package.json
@@ -6,7 +6,7 @@
"dependencies": {
"bcrypt-nodejs": "~0.0.3",
"consolidate": "~0.9.1",
- "express": ">=3.x",
+ "express": "^3.x",
"mongodb": "~1.3.9",
"swig": "~0.14.0",
"validator": "~1.1.3"
diff --git a/week-7/Final4/blog/posts.js b/week-7/Final4/blog/posts.js
index 0769fcf..59f4f3b 100644
--- a/week-7/Final4/blog/posts.js
+++ b/week-7/Final4/blog/posts.js
@@ -126,7 +126,15 @@ function PostsDAO(db) {
// is zero indexed).
// TODO: Final exam question - Increment the number of likes
- callback(Error("incrementLikes NYI"), null);
+ //callback(Error("incrementLikes NYI"), null);
+ var selector = {};
+ selector['comments.' + comment_ordinal + '.num_likes'] = 1
+ posts.update({'permalink': permalink}, {'$inc': selector}, function(err, numModified) {
+ "use strict";
+ if (err) return callback(err, null);
+ callback(err, numModified);
+ });
+
}
}