On this page本页内容
$skip
Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.跳过传递到该阶段的指定数量的文档,并将剩余文档传递到管道中的下一个阶段。
The $skip
stage has the following prototype form:$skip
阶段具有以下原型形式:
{ $skip: <positive 64-bit integer> }
$skip
takes a positive integer that specifies the maximum number of documents to skip.获取一个正整数,该整数指定要跳过的最大文档数。
Starting in MongoDB 5.0, the 从MongoDB 5.0开始,$skip
pipeline aggregation has a 64-bit integer limit. $skip
管道聚合具有64位整数限制。Values passed to the pipeline which exceed this limit will return a invalid argument error.传递给管道的值超过此限制将返回无效参数错误。
$skip
If using the 如果将$skip
stage with any of:$skip
阶段与以下任何一项一起使用:
$sort
aggregation stage,$sort
聚合阶段,sort()
method, orsort()
方法,或sort
field to the findAndModify
command or the findAndModify()
shell method,findAndModify
命令或findAndModify()
shell方法,be sure to include at least one field in your sort that contains unique values, before passing results to the 在将结果传递到$skip
stage.$skip
阶段之前,请确保在排序中至少包含一个包含唯一值的字段。
Sorting on fields that contain duplicate values may return a different sort order for those duplicate fields over multiple executions, especially when the collection is actively receiving writes.对包含重复值的字段进行排序可能会在多次执行时为这些重复字段返回不同的排序顺序,特别是当集合正在主动接收写入时。
The easiest way to guarantee sort consistency is to include the 保证排序一致性的最简单方法是在排序查询中包含_id
field in your sort query._id
字段。
See the following for more information on each:有关每一项的详细信息,请参阅以下内容:
Consider the following example:考虑以下示例:
db.article.aggregate([ { $skip : 5 } ]);
This operation skips the first 5 documents passed to it by the pipeline. 此操作跳过管道传递给它的前5个文档。$skip
has no effect on the content of the documents it passes along the pipeline.$skip
对沿管道传递的文档的内容没有影响。