
- Implement Todo CRUD API endpoints - Set up SQLite database with SQLAlchemy - Create Todo model and schemas - Configure Alembic migrations - Add comprehensive documentation 🤖 Generated with and Co-Authored by [BackendIM](https://backend.im)
38 lines
792 B
Python
38 lines
792 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Base Todo Schema for shared properties
|
|
class TodoBase(BaseModel):
|
|
title: str = Field(..., min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = False
|
|
|
|
|
|
# Schema for creating a todo
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
|
|
# Schema for updating a todo
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
# Schema for returning a todo
|
|
class TodoInDB(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Schema for public API
|
|
class Todo(TodoInDB):
|
|
pass |