Mongo: Limit returned records to an incremental count on slice
Use unwind
to deconstruct the documents, then limit it and group them again
var query = Model.aggregate( { $match: { id: id } }, { $sort: { created: -1 } }, { $unwind: '$array_data' }, { $limit: 20 }, { $group: { _id: { name:'$name', number: '$number', created: '$created', status: '$status', time: '$time' }, array_data: { $push: '$array_data' } } }, { $project: { name: '$_id.name', number: '$_id.number', created: '$_id.created', status: '$_id.status', time: '$_id.time', array_data: 1, _id: 0 } } )