diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-07 23:03:27 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-07 23:03:27 -0700 |
| commit | 9b73eb32ae3f43aee7255707abb5595a647079df (patch) | |
| tree | c87da681f7cd03b68d62264d85cd2ede19b518f9 /week-5 | |
| parent | 33111a887481d0a8ba0cb679c055edac854c4b69 (diff) | |
homework 5.2
Diffstat (limited to 'week-5')
| -rw-r--r-- | week-5/52.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/week-5/52.js b/week-5/52.js new file mode 100644 index 0000000..e266491 --- /dev/null +++ b/week-5/52.js @@ -0,0 +1,22 @@ +use test; +db.zips.aggregate([ + { + $match: { + $or: [{ state: 'CA'}, { state: 'NY'}], + pop: { $gte: 25000 } + } + }, + { + $project: { + _id: 0, + //state: '$state', + population: '$pop', + } + }, + { + $group: { + _id: '$state', + average: { $avg: '$population' } + } + }, +]) |
