Skip to content

Add dynamic filtering, sorting to GET /api/outfits #94

@rak3rman

Description

@rak3rman

Description

Enable an API user to be able to filter and sort (asc and desc) each data field passed by GET /api/outfits. This is going to be a tricky one to do right. If no sorting or filtering attributes are passed, then all results are returned (subject to pagination if implemented). Both the filtering and sorting should be abstracted away from the API implementation in services/outfits.ts as seperate functions (schema.ts or utils/ could be a good home for these functions). You'll likely have to do some sort of "query building" to whittle down to the result that the user wants. For filtering, only consider "AND" or inner joins for now. Filtering like this is common practice in the industry, search the web for best practices.

For example, consider the case where I'd like to filter by rating. The user should be able to pass in a parameter where rating = 2 and all returned values should contain an outfit with a rating of 2. For sorting, say I'd like to sort by rating as well in asc order. Then the returned values should be sorted by such.

Acceptance Criteria

Generated by Zenhub AI

  • Scenario: Filtering by rating
  • Given the user wants to filter by rating
  • When the user sends a GET request to /api/outfits with a parameter "rating=2"
  • Then the API should return all outfits with a rating of 2
  • Scenario: Sorting by rating in ascending order
    • Given the user wants to sort by rating in ascending order
    • When the user sends a GET request to /api/outfits with a parameter "sort=rating,asc"
    • Then the API should return the outfits sorted by rating in ascending order
  • Scenario: Filtering and sorting by rating
    • Given the user wants to filter by rating and sort by rating in ascending order
    • When the user sends a GET request to /api/outfits with parameters "rating=2" and "sort=rating,asc"
    • Then the API should return all outfits with a rating of 2 sorted in ascending order

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendRelated to the hono backend

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions