Make nested queries in MongoDB 3.0.7
<p>I have <strong>sub-events</strong> belonging to <strong>events</strong> belonging to an <strong>user</strong>, and I know the user's username - how do I get a list of the sub-events?</p>

<p>Is this going in the right direction? Or is it completely off?</p>

<pre><code>db.subevents.find({_id: {$in: 
    db.events.find({_id: {$in:
        db.users.find({"username":"userx"},{_id:1})}},{_id:1})}})
</code></pre>

<p><strong>Edit:</strong> Here is a sample of the data structure:</p>

<pre><code>/* Event */
{
  "_id" : "XjhAqqNBkezKY3mdN",
  "name" : "My event",
  "userId" : "FiKsAAAgBb7cNoPH7"
}
/* Subevent */
{
  "_id" : "WkYAqBXNpJryp7rum",
  "name" : "The subevent",
  "eventId" : "hQXNzX3jbWppbAYFH"
}
/* User */
{
  "_id" : "RTHh5srhLMQp625zF",
  "username" : "userx"
}
</code></pre>