diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-20 21:18:53 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-20 21:27:27 -0700 |
| commit | d7a8d6c7be1c2a292e6be53f8a7552d24431380a (patch) | |
| tree | 71d6fbb1a5ab17563b22cb71a4e50f9d78cb0397 | |
| parent | 8419ce131f9d933339495c12a644ac6ff747f116 (diff) | |
solve question 2 in exam.
| -rw-r--r-- | week-7/question2.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/week-7/question2.js b/week-7/question2.js new file mode 100644 index 0000000..2e6ba9e --- /dev/null +++ b/week-7/question2.js @@ -0,0 +1,34 @@ +use enron; + +//db.messages.findOne(); + +db.messages.aggregate([ + { + $match: { + $or:[ + { 'headers.From': 'susan.mara@enron.com' }, + { 'headers.From': 'soblander@carrfut.com' }, + { 'headers.From': 'evelyn.metoyer@enron.com' }, + ] + } + }, + { $unwind: '$headers.To' }, + { + $project: { + _id: '$headers.To', + to: '$headers.To', + from: '$headers.From', + } + }, + { + $group: { + _id: { + from: '$from', + to: '$to', + }, + sum: { $sum: 1 } + } + }, + { $sort: { sum: -1 } }, + { $limit: 1 } +]).pretty(); |
