title: mongo db how to join collections
body: <p>How to fetch records as join full outer in mongo db 3.2</p>
  
  <p>inventory collection</p>
  
  <pre><code>db.inventory.insert([
  { "_id" : 1, "coin_id" : "12345", description: "product 1"},
  { "_id" : 2, "coin_id" : "12346", description: "product 2"},
  ])
  </code></pre>
  
  <p>Order Collection</p>
  
  <pre><code>db.orders.insert([
  { "_id" : 1, "coin_id" : "12345", "user_id" : 11, "bal" :1000 },
  ])
  </code></pre>
  
  <p>Here Scenario is like that. i want to fetch reocrd from inventory collection on the basis of coin_id,then matching record from order collection. but if not matched on order  collection , it will be give at least inventory records .</p>
  
  <p>My code -:</p>
  
  <pre><code>db.inventory.aggregate([
  {
      $lookup:
      {
         from: 'orders',
         localField: 'coin_id',
         foreignField: 'coin_id',
         as: 'coin_details'
      }
  },  {$match : {'coin_details.user_id':'11')}}
  </code></pre>
  
  <p>I always want to records from inventory records whenever either user_id will empty or not available 
  If any other possibility available please let me know. please guide me how to do it.</p>