title: mongodb map reduce to get uniques by date/day
body: <p>trying to group by date and number</p>
  
  <p>my document </p>
  
  <pre><code> { "_id" : ObjectId("4f956dee76ddb26752026e8f"), "request" : "default", "options" : "1", "keyword" : "somekey", "number" : "5b234b79-4d70-437e-8eef-32a2941af40a", "date" : "20120423200446", "time" : 1335193066 }
  </code></pre>
  
  <p>my query</p>
  
  <pre><code>map = "function() { var date = new Date(this.time * 1000); var key = date.getFullYear() + date.getMonth() + date.getDate(); emit({day : key, number: this.number}, {count: 1}); }"
  
  reduce = "function(key, values) { var count = 0; values.forEach(function(v) { count += v['count']; }); return {count: count}; }"
  
  db.txtweb.mapReduce(map, reduce, {out: "pageview_results"});
  </code></pre>
  
  <p>my error</p>
  
  <pre><code>uncaught exception: map reduce failed:{ "errmsg" : "ns doesn't exist", "ok" : 0 }
  </code></pre>
  
  <p>I cannot figure out whats wrong, but I think it is do something with the date functionality.</p>
  
  <p>Any ideas.</p>