Get averages from pre-aggregated reports in mongodb

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2012-12-10T23:02:46Z Indexed on 2012/12/10 23:03 UTC
Read the original article Hit count: 177

Filed under:

I've got a database with pre-aggregated metrics similar to the one outlined in this use case: http://docs.mongodb.org/manual/use-cases/pre-aggregated-reports/

I have a daily collection with a subdocument for hour and minute metrics, and a 'metadata.date' entry for midnight on the day it represents. I also have a monthly collection with a day subdocument for each day.

If I want to get an average of a metric over the past eight or so days how can I do that with the aggregation framework? Is the aggregation framework not the right tool for this since it's already pre-aggregated?

© Stack Overflow or respective owner

Related posts about mongodb