title: Stats data scheme
body: <p>I'm going to collect a lot of stats data and count some values (like popularity). After that I need to display it as graph. I read <a href="http://docs.mongodb.org/ecosystem/use-cases/pre-aggregated-reports/" rel="nofollow">this article</a> and my task looks pretty simple: create document per each day, store data as described in article. When I'll need to get most popular values for last 3 days I'll just use aggregation framework. Very simple....</p>
  
  <p>But how can I get most popular values for last 24 hours in this case? I can filter documents for last 2 days but it != last 24 hours... </p>
  
  <p>Is it possible to be flexible in date range with scheme described above? </p>
  
  <p><strong>added:</strong></p>
  
  <p>Following data structure uses single document to store information for the whole day:</p>
  
  <pre><code>{
      _id: "20101010/site-1/apache_pb.gif",
      metadata: {
          date: ISODate("2000-10-10T00:00:00Z"),
          site: "site-1",
          page: "/apache_pb.gif" },
      daily: 5468426,
      hourly: {
          "0": 227850,
          "1": 210231,
          ...
          "23": 20457 },
      minute: {
          "0": 3612,
          "1": 3241,
          ...
          "1439": 2819 }
  }
  </code></pre>
  
  <p>Using aggregation framework I can select documents for last week (max 7), group by <code>metadata.site</code> and sum <code>daily</code> to get total visits by site. Is it possible to count total visits by site for last 24 hours with the scheme suggested above? </p>
  
  <p>(there is a simple way to create <code>by hour</code> documents but I don't wanna do it because of performance reasons)</p>