title: Paging arrays in mongodb subdocument
body: <p>I have a mongo collection with documents that have a schema structured like the following:</p>
  
  <pre><code>{ _id : bla,
    fname : foo,
    lname : bar,
    subdocs [ { subdocname : doc1
               field1 : one
               field2 : two
               potentially_huge_array : [...]
              }, ...
    ]
  }
  </code></pre>
  
  <p>I'm using the ruby mongo driver that currently does not support elemMatch.  I use an aggregation when extracting from subdocs via a project, unwind and match pipeline.</p>
  
  <p>What I would now like to do is to page results from the potentially_huge_array array contained in the subdocument.  I have not been able to figure out how to grab just a subset of the array without dragging the entire subdoc, huge array and all, out of the db into my app.</p>
  
  <p>Is there some way to do this?</p>
  
  <p>Would a different schema be a better way to handle this?</p>