Q:

Mongo finding items through subobject

Mongo finding items through sub-object
 { "_id" : ObjectId("4f93aaddaca610f76b000000"),
   "count" : NumberLong(2),
   "items" : [
            {"count" : NumberLong(1),
             "options":{ "1":"track","2" : "track" } },

            {"count":NumberLong(2),
             "options":{"1":"as","2" : "sadf" } }
             ]
 }

How to sort the things in the sub-objects like limit the items list per request 
result i expect is this
 { "_id" : ObjectId("4f93aaddaca610f76b000000"),
   "count" : NumberLong(2),
   "items" : [
            {"count" : NumberLong(1),
             "options":{ "1":"track","2" : "track" } },
             ]
 }

A:

No, you can't do that. Querying embedded arrays is pretty limited now. Some day we'll have virtual collections (SERVER-142) and we'll be able to do sort , skip, limit and all other usual things. But right now we have these options:

Fetch whole subarray and process it in the application;
Move items to their own collection (reference instead of embedding);
Use Aggregation Framework (not yet released);
Give up the idea.

