How to do inner joining in MongoDB?
<p>Is it possible to do SQL inner joins kind of stuff in MongoDB?</p>
<p>I know there is the <code>$lookup</code> attribute in an aggregation pipeline and it is equivalent to <strong>outer joins</strong> in SQL, but I want to do something similar to <strong>inner joins</strong>.</p>
<p>I have three collections which  need to merge together:</p>
<pre class="lang-javascript prettyprint-override"><code>// User Collection
db.User.find({});

// Output:
{
   ID : 1,
   USER_NAME : &quot;John&quot;,
   password : &quot;pass&quot;
}
{

   ID : 2,
   USER_NAME : &quot;Andrew&quot;,
   PASSWORD : &quot;andrew&quot;
}

// Role Collection
db.ROLE.find({});

// Output:
{
   ID : 1,
   ROLE_NAME : &quot;admin&quot;
},
{
    ID : 2,
    ROLE_NAME : &quot;staff&quot;
}

// USER_ROLE Collection
db.USER_ROLE.find({});

// Output:
{
   ID : 1,
   USER_ID : 1,
   ROLE_ID : 1
}
</code></pre>
<p>I have the above collections and I want to extract only the documents matched with users and their respective roles, not all the documents. How can I manage it in MongoDB?</p>