APIFeatures

APIFeatures class represents a utility for manipulating and filtering API queries.

Constructor:

  • query: The mongoose query object.
  • queryString: The query string object.

Methods:

  1. filter()
    • Description: Filter the query based on the provided query string.
    • Returns: The modified APIFeatures object.
  2. search()
    • Description: Perform a text search on the query using the provided search term.
    • Returns: The modified APIFeatures object.
  3. limitFields()
    • Description: Limit the fields returned in the query result.
    • Returns: The modified APIFeatures object.
  4. paginate()
    • Description: Paginate the query result.
    • Returns: The modified APIFeatures object.
  5. sort()
    • Description: Sort the query result.
    • Returns: The modified APIFeatures object.