title: How to write a query to $lookup, $group and $sum to show the output with input document
body: <p>I have 2 collections collection1 and collection2. I want to lookup two tables and group and sum the quantity. I tried grouping in collection 2 and lookup with collection1 but didnt get the ouput document correctly. Please help to find this problem.</p>
  <pre><code>//collection 1
  {
       _id: 1,
       name: Product1,
       units: 20
  },
  {
       _id: 2,
       name: Product2,
       units: 10
  },
  {
       _id: 3,
       name: Product3,
       units: 50
  },
  {
       _id: 4,
       name: Product4,
       units: 4
  }
  
  </code></pre>
  <pre><code>//collection2
  {
       _id2: 1,
      inventory: 1, //foreign key
       quantity: 20,
  },
  {
       _id2: 2,
       inventory: 1 //foreign key
       quantity: 10
  },
  {
       _id2: 3,
      inventory: 1 //foreign key
       quantity: 50
  },
  {
       _id2: 4,
      inventory: 2 //foreign key
       quantity: 4
  },
  {
       _id2: 5,
       inventory: 2 //foreign key
       quantity: 45
  },
  {
       _id2: 6,
       inventory: 3 //foreign key
       quantity: 49
  },
  
  </code></pre>
  <p>How to write a query in order to get output with collection1 data like this</p>
  <pre><code>{
       _id1: 1,
       name: Product1,
       units: 20,
       inventoryList: [quantity: 80]
  },
  {
       _id1: 2,
       name: Product2,
       units: 10,
       inventoryList: [quantity: 49]
  },
  {
       _id1: 3,
       name: Product3,
       units: 50,
       inventoryList: [quantity: 49]
  },
  {
       _id1: 4,
       name: Product4,
       units: 4,
       inventoryList: [quantity: 0]
  }
  
  </code></pre>