title: How to use like $dateToString in Aggregation $group for Spring Data Mongo
body: <p>I need to implement aggregation in Spring-Data MongoDB.</p>
  
  <p>This aggregation <code>$group</code> works successfully in Mongo Compass:</p>
  
  <pre><code>$group{
    {
      _id:  { $dateToString: { format: "%Y-%m-%d", date: "$date" }},
      doc: {"$push":"$$ROOT"}
  
    }
  }
  </code></pre>
  
  <p>This is the result expected group by year month and day and push results with all field in array docs
  <a href="https://i.stack.imgur.com/tmV9t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tmV9t.png" alt="Conmpass"></a></p>
  
  <p>I try to implement this aggregation Spring Mongo:</p>
  
  <p><a href="https://i.stack.imgur.com/mErWB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mErWB.png" alt="My implementation"></a></p>
  
  <p>My problem is that lose data and only get a date by the previous projection.</p>
  
  <p>I prefer not use the <code>$project</code> and only <code>$group</code> stage.</p>
  
  <p><a href="https://i.stack.imgur.com/dzvTd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dzvTd.png" alt="My actual result"></a></p>