diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-21 21:19:03 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-21 21:19:03 -0700 |
| commit | 191a4f4daa4c54357db20ee05b5bdb2a7ca5eada (patch) | |
| tree | 3197a99244df84f4b1ee2b088d7986df23ec49cc | |
| parent | b3cea2d8f1c0436e8be1f45b09f6c0fe42f7fb2a (diff) | |
solve final 4.
| -rw-r--r-- | week-7/Final4/blog/package.json | 2 | ||||
| -rw-r--r-- | week-7/Final4/blog/posts.js | 10 |
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); + }); + } } |
