Skip to content

Add pagination to GET /tasks/ and GET /users/ #5

Description

@Navashub

Description

As the database grows, returning every task or user in one response becomes a problem. Add skip and limit pagination to both list endpoints.

What to do

  • Add skip: int = 0 and limit: int = 10 query params to GET /tasks/
  • Add skip: int = 0 and limit: int = 10 query params to GET /users/
  • Pass both values through to the CRUD functions
  • Apply them in the SQLAlchemy query using .offset(skip).limit(limit)
  • Update the README table of endpoints to document the new params

Acceptance Criteria

  • GET /tasks/?skip=0&limit=5 returns at most 5 tasks starting from the first
  • GET /tasks/?skip=5&limit=5 returns the next 5
  • Same behaviour for /users/
  • Default behaviour (no params) returns the first 10 results

Hints

  • FastAPI handles query params automatically when declared as function arguments
  • SQLAlchemy: db.query(Task).offset(skip).limit(limit).all()

Difficulty

🟡 Intermediate

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendPython / FastAPI workintermediateRequires some FastAPI experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions