Created
May 27, 2015 21:19
-
-
Save peterzawistowicz/82b16920983cdd30f94b to your computer and use it in GitHub Desktop.
This file contains 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 map = function() { emit(this.userId, 1); } // emit samples by userId with value of 1 | |
var reduce = function(key, values) | |
{ return Array.sum(values); } // sum the total samples per user | |
db.activities.mapreduce(map, reduce, | |
{ query: { time: { $gt: NOW-1H } }, // time bound the query to the last hour | |
out: { replace: "lastHourUniques", sharded: true }) // persist the output to a collection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment