MongoDB equivalent of SQL "TOP"
Short question, short answer: you can achieve this with sort()
and limit()
.limit()
Example:
db.things.find().limit(10)
Documentation: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D
As per the comment below, technically, you'd want to sort the collection too, so it would be:
db.things.find().sort({someField:1}).limit(10)