Finding Documents

Finding Documents: Finding Documents with Filters, Sorting and Paging Results.

Updated

  1. Finding Documents with Filters (Apprentice): A filter object tells find and findOne which documents you want, with operators such as $gte and $in for comparisons, dot notation for a field inside a field, an ObjectId to find one document by its id, and a projection to send back only the fields you need.
  2. Sorting and Paging Results (Journeyman): sort puts a query's results in order, skip and limit cut out one page of them, and countDocuments counts every match, so an API can answer with page 2 of 3 instead of every document at once.