Limit the Number of Returned Documents限制返回文档的数量

If the query bar has the Limit option, you can specify the maximum number of documents to return.如果查询栏具有“限制”选项,则可以指定要返回的最大文档数。

To specify the limit:要指定限制,请执行以下操作:

  1. In the Query Bar, click Options.在查询栏中,单击“选项”。
  2. Enter an integer representing the number of documents to return into the Limit field.输入一个整数,表示要返回到“限制”字段的文档数。
  3. Click Find to run the query and view the updated results.单击“查找”以运行查询并查看更新的结果。

    Results of specifying query limit
    click to enlarge

To clear the query bar and the results of the query, click Reset.要清除查询栏和查询结果,请单击“重置”。

See the limit entry in the MongoDB Manual.请参阅MongoDB手册中的limit条目。

$skip corresponds to the LIMIT ... clause in a SQL SELECT statement.$skip对应于SQL SELECT语句中的LIMIT ...子句。

Example

You have 3,235 articles. You would like to see a list of the first 10 articles.你有3235篇文章。您希望看到前10篇文章的列表。

SQL
SELECT * FROM article
LIMIT 10;
MongoDB Aggregation
db.article.aggregate(
  { $limit : 10 }
);
Compass Limit Option
$limit : 10