title: How to join two collection in mongodb similar like inner join in mysql
body: <p><strong>first collection : <code>transactions</code></strong></p>
  
  <pre><code>{
    "_id": "QH2yYgJyE8A1zKBAWTv_T0VmvceS5l7p15Lki_i2PwfGoV3kHzkeqa6yFFm5oLhwriF39bAl2b4wgSIkvwy-MA",
    "rate": [
      {
        "user_id": ObjectId("58aeb5bd21b8ae596d3c9869"),
        "rate": "4",
        "option": "QUICK_BITE",
        "message": "Good"
      }
    ]
  }
  </code></pre>
  
  <p><strong>Second collection : <code>users</code></strong></p>
  
  <pre><code>{
    "_id": ObjectId("58aeb5bd21b8ae596d3c9869"),
    "username": "ravi",
    "profile": {
      "firstname": "Ravi",
      "lastname": "Kumar",
      "email": "ravi@gamil.com",
      "phone_no": "",
      "company_name": "gmail",
      "image": ""
    }
  },
  {
    "_id": ObjectId("58c104da21b8aeac733c9869"),
    "username": "",
    "profile": {
      "firstname": "lalit",
      "lastname": "sharma",
      "email": "lxyz@gmail.com",
      "phone_no": "",
      "company_name": ""
    }
  },
  {
    "_id": ObjectId("58c12afc21b8aef8553c9869"),
    "username": "",
    "profile": {
      "firstname": "Aijaz",
      "lastname": "Haidar",
      "email": "jazhaidar@gmail.com",
      "phone_no": "",
      "company_name": "yahoo",
      "image": ""
    }
  }
  </code></pre>
  
  <p>I want to join <code>users</code> collection with <code>transactions</code> collection so that i should get the users full profile detail in rate feild.</p>
  
  <p><strong>Output something like</strong> </p>
  
  <pre><code> {
      "_id" : ObjectId("58c1200321b8ae2d413c98a5"),
      "rate" : [
          {
              "rate" : "4",
              "option" : "QUICK_BITE",
              "message" : "Good",
              "profile" : {
                  "firstname" : "Ravi",
                  "lastname" : "Kumar",
                  "email" : "ravi@gamil.com",
                  "phone_no" : "",
                  "company_name" : "gmail",
                  "image" : ""
              }
          }
      ]
  } 
  </code></pre>
  
  <p>Right now I'm merge both collections using <code>$lookup</code> in the following way:</p>
  
  <pre><code>db.transactions.aggregate([ 
      {$lookup: {
             from: "users",
             localField: "rate.user_id",
             foreignField: "_id",
             as: "profile"
           }}
  ]);
  </code></pre>
  
  <p>But above query is not working :(    </p>