Created
April 11, 2014 17:27
-
-
Save lorgio/10486067 to your computer and use it in GitHub Desktop.
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 characters
| var values = [] | |
| var map = function() { | |
| emit(key, value); | |
| }; | |
| var emit = function(key,value){ | |
| // print("key: "+ tojsononeline(key) +" value: "+ tojsononeline(value)); | |
| output = {"_id": key, value: value} | |
| print(output) | |
| values.push(value) | |
| } | |
| var myCursor = db.events.find( { created_at: {$gt: ISODate("2014-03-03T00:00:09.043Z")}}) | |
| while (myCursor.hasNext()) { | |
| var doc = myCursor.next(); | |
| map.apply(doc) | |
| } | |
| var reduce = function(key, values) { | |
| var reducedValue = {key: key, values: null}; | |
| values.forEach(function(value) { | |
| // put your reduce code in here | |
| // reducedValue.values = something | |
| }); | |
| return reducedValue; | |
| }; | |
| reduce('mykey', values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment