Shaping Results

Shaping Results: Choosing Fields with Projections, Sorting and Paging: sort, limit and skip.

Updated

  1. Choosing Fields with Projections (Apprentice): A projection, the second argument to find, chooses which fields come back; 1 includes a field and 0 leaves it out, _id comes along unless you leave it out, and the two can't be mixed except for _id.
  2. Sorting and Paging: sort, limit and skip (Apprentice): sort puts results in order (1 up, -1 down) with a second field to break ties, limit caps how many come back, skip passes over the pages before, and countDocuments gives the number of pages.