title: Retrieving a Subset of Fields from MongoDB in Ruby
body: <p>I'm trying to get a subset of fields from MongoDB with a query made in Ruby but it doesn't seem to work. It doesn't return any results</p>
  
  <p>This is the ruby code:</p>
  
  <pre><code>coll.find("title" =&gt; 'Halo', :fields =&gt; ["title", "isrc"]) #this doesn't work
  </code></pre>
  
  <p>If I remove the fields hash, it works, returning the results with all the fields</p>
  
  <pre><code>coll.find("title" =&gt; 'Halo') #this works
  </code></pre>
  
  <p>Looking at the mongodb console the first query ends-up on the mongodb server like this:</p>
  
  <pre><code>{ title: "Halo", fields: [ "title", "isrc" ] }
  </code></pre>
  
  <p>If I try to make the query from the mongo client console, it works, I get the results and the subset. I make the query like this:</p>
  
  <pre><code>db.tracks.find({title: 'Halo'}, {title:1,isrc:1})
  </code></pre>
  
  <p>What could be the problem? I've been looking for a solution for this for a couple of hours now.</p>