使用$slice
.
db.foo.find({ bar : "xyz" } , { my_array : { $slice : [n , 1] } } )
将检索foo集合中所有文档的数组"my_array"的第n个元素,其中bar="xyz".
MongoDB文档中的其他一些示例:
db.posts.find({}, {comments:{$slice: 5}}) // first 5 comments
db.posts.find({}, {comments:{$slice: -5}}) // last 5 comments
db.posts.find({}, {comments:{$slice: [20, 10]}}) // skip 20, limit 10
db.posts.find({}, {comments:{$slice: [-20, 10]}}) // 20 from end, limit 10
你可以在这里读到:http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields