
- Set up project structure with FastAPI and SQLite - Implement Todo model, schemas, and CRUD operations - Set up Alembic for database migrations - Add health endpoint for application monitoring - Update README with project information generated with BackendIM... (backend.im)
24 lines
861 B
Python
24 lines
861 B
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
class TodoBase(BaseModel):
|
|
title: str = Field(..., min_length=1, max_length=100, description="Todo title")
|
|
description: Optional[str] = Field(None, max_length=500, description="Todo description")
|
|
completed: bool = Field(False, description="Completion status")
|
|
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, min_length=1, max_length=100, description="Todo title")
|
|
description: Optional[str] = Field(None, max_length=500, description="Todo description")
|
|
completed: Optional[bool] = Field(None, description="Completion status")
|
|
|
|
class TodoResponse(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True |