title: Mongo aggregation of list
body: <p>I have collection like this:</p>
  
  <pre><code>{id:1, name: "fluffy", 
    toys: [{id: "mouse", colors: ['red', 'green']}, 
           {id: "yarn", colors: ['blue', 'green']]
  },
  
  {id:2, name: "rex", 
    toys: [{id: "bone", colors: ['gray']}]
  }  
  </code></pre>
  
  <p>I want to see results like this:</p>
  
  <pre><code>[
    {id: 1, name:"fluffy", toyColors:["red", "green", "blue"]},
    {id: 2, name:"rex", toyColors:["gray"]} 
  ]
  </code></pre>
  
  <p>I tried something like this, but I got 'lists of lists', instead of one big list for toy colors. Also, I did not know how to select the pet name with a query like this.</p>
  
  <pre><code>db.pets.aggregate({$group:{_id: "$id", toyColors: {$addToSet: "$toys.colors"}}})
  </code></pre>