title: Retrieve Max value from a field using Spring Data and MongoDB
body: <p>I want to obtain the maximum value of the field <code>code</code> within my <code>User</code> entity, using Spring Data and MongoDB.</p>
  <p>I have seen similar examples using as below,</p>
  <pre><code>&quot;.find({}).sort({&quot;updateTime&quot; : -1}).limit(1)&quot;
  </code></pre>
  <p>But have no idea how to integrate it into my own <code>repository</code> using the <code>@Query</code> annotation.</p>
  <p>Any alternative solution, than to return the maximum value of said field is also welcome.
  Thank you.</p>