title: How do I get the last item in a MongoDB collection?
body: <p>I'm using MongoDB for sometime to perform all sort of fast inserts or having as a log, but I'm having some trouble to get a <strong>really simple query</strong></p>
  
  <p>How, in Mongo, would I do to get a similiar to this T-SQL</p>
  
  <pre><code>SELECT TOP 1 [date] FROM [Collection] ORDER BY [date] desc
  </code></pre>
  
  <p>In other words, what is the last date in the collection.</p>
  
  <p>I'm trying to use <code>FindOne</code> or any other that can return one document, but none accepts a <code>sortBy</code> property... how would I do this?</p>
  
  <pre><code>var query = Query.EQ("status", "pending");
  var sortBy = SortBy.Descending("date");
  
  return collectionLog.FindOneAs&lt;BsonDocument&gt;(query, sortBy);
  </code></pre>
  
  <p>The last line above would be perfect, but this method only accepts the <code>query</code> parameter.</p>