title: Mongo lookup returning all values
body: <p>I have 2 collections as shown below:</p>
  
  <pre><code>branches
  {
    _id: ..., 
    custId: "abc123",
    branchCode: "AA",
  ...other fields
  }
  
  branchHolidays
  {
    _id: ..., 
    custId: "abc123", 
    holidayDate: ISODate("2019-06-01T00:00:00:0000"),
    holidayStatus: "PROCESSED",
  ..other fields
  }
  
  </code></pre>
  
  <p>Need to get all <strong>branchHolidays</strong> with the custId available in <strong>branches</strong> collection along with the branchCode from <strong>branches</strong> collection. (branches.custId = branchHolidays.custId)</p>
  
  <p>For the first part of join I tried the below query but I'm getting all the fields from <strong>branchHolidays</strong> collection.</p>
  
  <pre><code>db.getCollection('branchHolidays').aggregate([
  {
    $lookup: {
      localField: "custId",
      from: "branches",
      foreignField: "custId",
      as: "holidays"
    }
  },
  $match: {  holidayStatus: "PROCESSED" }
  ])
  </code></pre>
  
  <p>The above query returns all the documents from <strong>branchHolidays</strong> collection. 
  I'm new to mongo but I'm not able to figure out what the problem is. Have gone through most of the SO queries but haven't found anything which helped.</p>
  
  <p>Note: There are multiple branchCodes mapped to 1 custId in <strong>branches</strong> collection.</p>