title: MongoDB: Retrieving the first document in a collection
body: <p>I'm new to Mongo, and I'm trying to retrieve the first document from a <code>find()</code> query:</p>
  
  <pre><code>&gt; db.scores.save({a: 99});
  &gt; var collection = db.scores.find();
  [ 
    {   "a" : 99,   "_id" : {   "$oid" : "51a91ff3cc93742c1607ce28"   }   }
  ]
  &gt; var document = collection[0];
  JS Error: result is undefined
  </code></pre>
  
  <p>This is a little weird, since a collection looks a lot like an array. I'm aware of retrieving a single document using <code>findOne()</code>, but is it possible to pull one out of a collection?</p>