Docs Menu

$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 ビットの整数制限があります。この制限を超える値がパイプラインに渡されると、無効な引数エラーが返されます。

$skip ステージを次のいずれかで使用する場合、

結果を $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.

以下も参照してください。

項目一覧