getWeek(date) to MongoDB/Mongoid and how to use it from a map/reduce.
add_stored_function method comes from the Ruby MongoDB driver. Call
Let’s now map/reduce our widgets into widgets_weekly using the created_at timestamp. Notice the call to getWeek.
This yields the following collection in widgets_weekly.
If anyone knows of a library that does this kind of rollups, OLAP cubes or any other data transformation for reporting purposes with MongoDB/Mongoid, please speak up!