Mongoose populate options limit, how to limit number of sub document?
<p>I have a query to find an account and populate sub doc of the account.</p>

<p>When I use populate path:"orders" the limit option will work. But if I use populate path"orders.order", the option limit will not work.</p>

<p>What should I do?</p>

<p>My schema is like:</p>

<pre><code>  var AccountSchema = new mongoose.Schema({

    _id:id,
    orders:{type:[{
      order:{type: mongoose.Schema.Types.ObjectId, ref:'Order'}
    }]}
  });


var findOrderByUserId = function(accountId,index,count,callback){
  var limit = index*count;
  console.log(limit);
  Account.findOne({_id:accountId}).populate({
    path:'orders.order',//If path is orders, then limit will work

    options:{
      limit:limit
    }
  }).exec(function (err, doc) {
              if (err) {
                console.log(err);
                callback(err);
              }
              console.log(doc);
                var array = [];
                for(var i=limit - count;i&lt;doc.orders.length;i++){
                    if(doc.orders[i]!=null){
                        array.push(doc.orders[i]);            
                    }
                    else{
                      break;
                    }
                }
              callback(doc);
          })
}
</code></pre>