Limit the Number of Returned Documents限制返回文档的数量¶
If the query bar has the Limit option, you can specify the maximum number of documents to return.如果查询栏具有“限制”选项,则可以指定要返回的最大文档数。
Set Documents to Return设置要返回的文档¶
To specify the limit:要指定限制,请执行以下操作:
In the Query Bar, click Options.在查询栏中,单击“选项”。Enter an integer representing the number of documents to return into the Limit field.输入一个整数,表示要返回到“限制”字段的文档数。Click Find to run the query and view the updated results.单击“查找”以运行查询并查看更新的结果。click to enlarge
Clear the Query清除查询¶
To clear the query bar and the results of the query, click Reset.要清除查询栏和查询结果,请单击“重置”。
To Learn More了解更多¶
See the 请参阅MongoDB手册中的limit
entry in the MongoDB Manual.limit
条目。
How Does the Compass Query Compare to MongoDB and SQL Queries?Compass查询与MongoDB和SQL查询相比如何?¶
$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