Created
May 27, 2015 21:20
-
-
Save peterzawistowicz/aa5482aa594c2e75acbb 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(userId, this.itemId); } // emit samples as userId: itemId | |
var reduce = function(key, values) | |
{ return values; } // Return the array of itemIds the user has bought | |
db.activities.mapReduce(map, reduce, | |
{ query: { type: “ORDER”, time: { $gt: NOW-24H }}, // include only activities of type order int he last day | |
out: { replace: "lastDayOrders", 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