Skip to content

Filter tasks by owner_id via query param #6

Description

@Navashub

Description

Currently anyone can see all tasks. Add an owner_id query param to GET /tasks/ so a frontend can fetch only a specific user's tasks.

What to do

  • Add an optional owner_id: Optional[int] = None query param to GET /tasks/
  • When provided, filter the SQLAlchemy query: .filter(Task.owner_id == owner_id)
  • When not provided, return all tasks (existing behaviour)
  • Update crud.py to accept owner_id as an optional argument

Acceptance Criteria

  • GET /tasks/?owner_id=1 returns only tasks belonging to user 1
  • GET /tasks/ (no param) returns all tasks
  • Returns an empty list (not an error) if the user has no tasks

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