diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-07 22:33:12 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-07 22:33:12 -0700 |
| commit | dfb8675455b56bcc8a9b39fb191b26d50cb808f9 (patch) | |
| tree | 6dc5dfecce7e50092bcc3b2a3815e4d5cb1e3e99 | |
| parent | 603918f2f0a9a20cfb9f93cbcba27acd26f44ed9 (diff) | |
answer for hw 1 week 5.
| -rw-r--r-- | week-5/hw5.2.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/week-5/hw5.2.js b/week-5/hw5.2.js new file mode 100644 index 0000000..5c5e672 --- /dev/null +++ b/week-5/hw5.2.js @@ -0,0 +1,7 @@ +db.posts.aggregate([ +{ $project: { comments: 1 } }, +{ $unwind: '$comments' }, +{ $group: { _id: '$comments.author', comment_count: { $sum: 1 } } }, +{ $sort: { comment_count: -1 } }, +{ $limit: 1 } +]) |
