Aggregate analytics data by day/next day logic
<p>I wrote a server for mobile app analytics in which I have a sharded(<strong>!Upd</strong>) collection with events as follows:</p>

<pre><code>{
  "event": "install",
  "userId": "a",
  "time": 2014-02-09,
  "data" : ...
},
{
  "event": "login",
  "userId": "a",
  "time": 2014-02-12,
  "data" : ...
},
{
  "event": "install",
  "userId": "b",
  "time": 2014-4-29,
  "data" : ...
},
{
  "event": "login",
  "userId": "b",
  "time": 2014-4-30,
  "data" : ...
}
...
</code></pre>

<p>I need to select users, who have the event <code>install</code> and not <code>login</code> in next day after the <code>install</code> event (in other words, I want to select Users who install the app, but do not login in next day). So the output for above data should be:</p>

<pre><code>{
   "userId": "a",
   "data" : ...
}
</code></pre>

<p>How do carry out this task with aggregation framework or mapreduce? Or maybe another solution?</p>