title: How to join to two additional collections with conditions
body: <pre><code>select tb1.*,tb3 from tb1,tb2,tb3
   where tb1.id=tb2.profile_id and tb2.field='&lt;text&gt;'
   and tb3.user_id = tb2.id and tb3.status =0
  </code></pre>
  
  <p>actually i converted the sql as <code>mongo</code> sql as follows </p>
  
  <p><code>mongo</code> sql which i used</p>
  
  <pre><code>db.getCollection('tb1').aggregate
  ([
    { $lookup: 
             { from: 'tb2', 
               localField: 'id', 
               foreignField: 'profile_id', 
               as: 'tb2detail' 
              } 
     },
  
     { $lookup: 
              { from: 'tb3', 
                localField: 'tb2.id', 
                foreignField: 'user_id', 
                as: 'tb3details' 
              } 
      },
  
  { $match: 
          { 'status': 
                    { '$ne': 'closed' 
                    }, 
            'tb2.profile_type': 'agent', 
            'tb3.status': 0 
           } 
  }
  
  ])
  </code></pre>
  
  <p>but not getting as per the expected result..</p>
  
  <p>Any help will be appreciated..</p>