
- Set up project structure and requirements - Create database models and connection - Set up Alembic for migrations - Implement CRUD operations for todos - Build RESTful API endpoints - Update README with project documentation generated with BackendIM... (backend.im)
32 lines
862 B
Python
32 lines
862 B
Python
from pydantic import BaseModel, Field
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
|
|
class TodoBase(BaseModel):
|
|
title: str = Field(..., title="The title of the todo", min_length=1)
|
|
description: Optional[str] = Field(None, title="The description of the todo")
|
|
completed: bool = Field(False, title="Whether the todo is completed")
|
|
|
|
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, title="The title of the todo", min_length=1)
|
|
description: Optional[str] = Field(None, title="The description of the todo")
|
|
completed: Optional[bool] = Field(None, title="Whether the todo is completed")
|
|
|
|
|
|
class TodoInDB(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class Todo(TodoInDB):
|
|
pass |