$skip (aggregation)
定義
$skip
Skips over the specified number of ドキュメント that pass into the stage and passes the remaining documents to the next stage in the パイプライン.
$skip
ステージのプロトタイプ形式は次のとおりです。{ $skip: <positive 64-bit integer> } $skip
takes a positive integer that specifies the maximum number of documents to skip.注意
MongoDB 5.0 以降では、
$skip
パイプライン集計に 64 ビットの整数制限があります。この制限を超える値がパイプラインに渡されると、無効な引数エラーが返されます。
動作
Using $skip with Sorted Results
$skip
ステージを次のいずれかで使用する場合、
$sort
集約段階、sort()
メソッド、またはfindAndModify
コマンドまたは
findAndModify()
shellメソッドに対するsort
フィールド
結果を $skip
ステージに渡す前に、一意の値を含むフィールドを 1 つ以上ソートの中に含めるようにします。
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.
並べ替えの整合性を保証する最も簡単な方法は、並べ替えクエリに_id
フィールドを含めることです。
それぞれの詳細については、以下を参照してください。
例
次の例で考えてみます。
db.article.aggregate([ { $skip : 5 } ]);
This operation skips the first 5 documents passed to it by the
pipeline. $skip
has no effect on the content of the
documents it passes along the pipeline.
以下も参照してください。