In addition to the query
object, most of the methods of retrieving documents using the MongoDB Node.js driver also include an options
object. The options
object allows you to define the behavior of the request when retrieving documents. It allows you to limit the result set, sort items while creating the result set, and much more.
Table 15.2 lists the options that can be set on methods that retrieve documents from the MongoDB server. Not all of these methods are available on every request. For example, when counting items that match a query, it doesn’t make sense to specify a limit on the result.