Skip a Number of Documents跳过一些文档

If the query bar displays the Skip option, you can specify how many documents to skip before returning the result set.如果查询栏显示“跳过”选项,则可以指定在返回结果集之前要跳过的文档数。

To specify the number of documents to skip:要指定要跳过的文档数,请执行以下操作:

  1. In the Query Bar, click Options.在查询栏中,单击“选项”。
  2. Enter an integer representing the number of documents to skip into the Skip field.在“跳过”字段中输入一个整数,表示要跳过的文档数。

    Results of using the Skip option
    click to enlarge
  3. Click Find to run the query and view the updated results.单击“查找”以运行查询并查看更新的结果。

    Note

    For query result sets larger than 1000 documents, Compass shows a sampling of the results. 对于大于1000个文档的查询结果集,Compass显示结果的采样。Otherwise, Compass shows the entire result set.否则,Compass将显示整个结果集。

    For details on sampling, see Sampling.有关采样的详细信息,请参阅采样

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

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

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

Example

You have a 3,235 articles. You would like to see a list of articles grouped in blocks of 50, starting with the 436th record.你有3235篇文章。您希望看到以50块为一组的文章列表,从第436条记录开始。

SQL
SELECT * FROM article
LIMIT 50 OFFSET 435;
MongoDB Aggregation
db.article.aggregate(
  { $limit : 50 },
  { $skip : 435 }
);
Compass Skip Option
$skip : 435