Skip to content

BE-7: Pagination & Filtering (GET /books) #7

Description

@tecnodeveloper

Enhance the GET /books endpoint to support pagination and basic filtering.

User Story

Given many books exist
When I request books with query params
Then I should receive paginated and filtered results

Query Params

  • page (default: 1)
  • limit (default: 10)
  • author (optional)
  • minPrice (optional)
  • maxPrice (optional)

Tasks

  • Update GET /books endpoint

  • Parse query params:

    • page
    • limit
    • author
    • minPrice
    • maxPrice
  • Implement pagination logic (OFFSET / LIMIT)

  • Implement filtering:

    • Filter by author
    • Filter by price range
  • Return metadata:

    • total
    • page
    • limit
  • Add Swagger documentation

    • Query params
    • Example requests

Acceptance Criteria

  • Pagination works correctly
  • Filtering works independently and combined
  • Default values applied if params missing
  • Response includes metadata
  • Swagger UI supports testing

Testing Steps

  • Add multiple book records

  • Test:

    /books?page=1&limit=5
    
  • Test filtering:

    /books?author=John
    /books?minPrice=50&maxPrice=200
    
  • Verify results match DB queries

Definition of Done

  • Pagination implemented
  • Filtering implemented
  • Swagger updated
  • Code linted and formatted

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions