MongoDB Using aggregate and $lookup to simulate a JOIN of collections in Mongo
<p>So I have collections <code>projects</code> which has field <code>contacts.envCon.$id</code>:</p>

<pre><code>     {
       "contacts" : {
            ...
            "envCon" : {
                "$ref" : "contacts",
                "$id" : ObjectId("5807966090c01f4174cb1714") &lt;---- NOTICE!!!
            }
            ...
        }
   }
</code></pre>

<p>On <code>contacts</code> collection Object with id <code>Example12345</code> looks like this: </p>

<pre><code>{
    "_id" : ObjectId("5807966090c01f4174cb1714"),
    "name" : "Terracon"
}
</code></pre>

<p>So I tried the following $lookup from aggregation framework:</p>

<pre><code>db.getCollection('projects').aggregate([
    {
            $lookup:{
                    from: "contacts",
                    localField: "contacts.envCon.id",
                    foreignField: "id",
                    as: "example"
            }
    }
]);
</code></pre>

<p>But it is not doing the JOIN what am I missing? how to do lookups between 2 collections using <code>contacts.envCon.id</code> from projects and <code>_id</code> from contacts.</p>

<p>I'm using meteor just in case.</p>