summaryrefslogtreecommitdiff
path: root/week-5
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-02-07 23:03:27 -0700
committermo khan <mo@mokhan.ca>2015-02-07 23:03:27 -0700
commit9b73eb32ae3f43aee7255707abb5595a647079df (patch)
treec87da681f7cd03b68d62264d85cd2ede19b518f9 /week-5
parent33111a887481d0a8ba0cb679c055edac854c4b69 (diff)
homework 5.2
Diffstat (limited to 'week-5')
-rw-r--r--week-5/52.js22
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' }
+ }
+ },
+])