title: Project only certain fields when using MongoTemplate from Spring Data MongoDB for a find query?
body: <p>I wonder how, if possible, I can execute a find query with Spring Data MongoDB using <code>mongoTemplate</code> but not return the entire document? With the &quot;native&quot; Java Sync driver from MongoDB I can do like this:</p>
  <pre><code>Document document = myCollection.find(eq(&quot;something&quot;, 12)).sort(descending(&quot;field&quot;)).limit(1).projection(include(&quot;field&quot;)).first();
  </code></pre>
  <p>so that the <code>document</code> only includes the &quot;field&quot; and nothing else.</p>
  <p>How can I do the same with <code>mongoTemplate</code> since I cannot seem to find something similar to <code>projection</code> when using <code>mongoTemplate.findOne(..)</code>. Do you need to using an Aggregate pipeline to do this with <code>mongoTemplate</code>?</p>
  <p>I'm using Spring Data MongoDB version 3.0.1.RELEASE (spring boot 2.3.3).</p>