title: Querying last 30 days date range with Mongoid and Ruby?
body: <p>How do I go about querying a date range (of say the last 30 days from now) with Mongoid and Ruby?</p>
  
  <p>I need to end up with an array or hash like the following:</p>
  
  <pre><code>{
      15 =&gt; 300,
      14 =&gt; 23,
      13 =&gt; 23
      ...
      30 =&gt; 20  # Goes over into previous month
      28 =&gt; 2
  }
  </code></pre>
  
  <p>I am currently storing each document with a DateTime instance as well as a unix timestamp Integer field. </p>
  
  <p>The keys in the above hash are the days and the values are the sum of all sales for those days. </p>
  
  <p>Any ideas?</p>