title: How to join two collections from different databases in MongoDB aggregate query?
body: <p>I have two collections <strong><em>[edit] in two different databases.</em></strong> Say it as <code>collection_a</code> and <code>collection_b</code>. </p>
  
  <blockquote>
    <p><strong>collection_a</strong>  document </p>
  </blockquote>
  
  <pre><code>{
      "_id": {
          "$binary": {
               "base64": "y5tcYX6t3kCCUHJtFF+RHg==",
               "subType": "03"
          }
      },
      "name": "some_name"
  }
  </code></pre>
  
  <blockquote>
    <p><strong>collection_b</strong> document</p>
  </blockquote>
  
  <pre><code>{
      "_id": {
          "$binary": {
             "base64": "DT+2QXMycUuX1xLdiFNO5w==",
              "subType": "03"
          }
      },
      "parentId": {
          "$binary": {
              "base64": "y5tcYX6t3kCCUHJtFF+RHg==",
              "subType": "03"
          }
      },
      "Status": "Completed",
      "Progress": {
          "$numberDouble": "100"
      }
  }
  </code></pre>
  
  <p>How to get <code>name</code> from <code>collection_a</code> using $lookup from <code>collection_b</code> ? 
  Trying something like below, but I see no results. </p>
  
  <pre><code>db.collection_b.aggregate([
        {
     $lookup:
       {
         from: 'collection_a',
         localField: 'parentId',
         foreignField: '_id',
         as: 'name'
       }
  }
  ])
  
  
  
  </code></pre>
  
  <blockquote>
    <p>lookup only works if both collections are in the same database. </p>
  </blockquote>