Pipeline Practice

MongoDB $limit

Allow only the first number of documents to continue.

The current order matters. Limiting before sorting answers a different question from sorting the full stream and then limiting it.

Stages are the top-level steps in a pipeline. Each stage receives documents, changes the stream in one specific way, and passes its output to the next stage.

Course use: Exercises 03, 11, and Hard Mode 13.

Example pipeline syntax

{ $limit: 3 }