Last active
December 28, 2015 15:59
-
-
Save amanrx07/7525940 to your computer and use it in GitHub Desktop.
Revisions
-
aman singh revised this gist
Nov 18, 2013 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,10 +24,8 @@ var options = { db.orders.mapReduce(map, reduce, options) /* Output: > db.order_totals.find() { "_id" : "A123", "value" : 750 } { "_id" : "B212", "value" : 200 } */ -
aman singh revised this gist
Nov 18, 2013 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,4 +21,13 @@ var options = { out: "order_totals" } db.orders.mapReduce(map, reduce, options) /* Output: > db.order_totals.find() { "_id" : "A123", "value" : 750 } { "_id" : "B212", "value" : 200 } */ -
aman singh renamed this gist
Nov 18, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
aman singh created this gist
Nov 18, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ use tutorial db.orders.insert({ cust_id: "A123", amount: 500, status: "A" }) db.orders.insert({ cust_id: "A123", amount: 250, status: "A" }) db.orders.insert({ cust_id: "B212", amount: 200, status: "A" }) db.orders.insert({ cust_id: "A123", amount: 300, status: "D" }) // Calculate the sum of all “amount”s for a unique “cust_id” var map = function() { emit(this.cust_id, this.amount); } var reduce = function(keyCustId, values) { return Array.sum(values); } var options = { query: { status: "A" }, out: "order_totals" } db.orders.mapReduce(map, reduce, options)