title: MongoDB Aggregate Project + Unwind empty array
body: <p>I solved the same problem the author of this question had with the solution the other guy posted as an answer: 
  <a href="https://stackoverflow.com/questions/22114748/unwind-empty-array-in-mongodb#">Unwind empty array in mongodb</a></p>
  
  <p>These days i updated my mongodb/mongoose and now i am getting an error:</p>
  
  <p><em>MongoError: The top-level _id field is the only field currently supported for exclusion</em></p>
  
  <p>It seems like mongo tries to "exclude" this field from the project now because of the 0 value. </p>
  
  <p>I need to add an array with an object with {value:0} because otherwise this object will be ignored after the unwind.</p>
  
  <pre><code>  { $match: parameter},
    { $unwind : "$items" },
    { $project: {
      itemName: '$items.name'},
      itemValue : "$items.value",
      discount : { $cond : [ { $eq : ["$items.discounts", [] ]}, [ { value : 0} ], '$items.discounts'] } 
    }},  
    { $unwind: "$discount"},
  </code></pre>
  
  <p>Is there any other/newer solution to this problem? 
  Thanks for your help.</p>