39 lines
814 B
Python
39 lines
814 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
# Shared properties
|
|
class TodoBase(BaseModel):
|
|
title: str = Field(..., min_length=1, max_length=255)
|
|
description: Optional[str] = None
|
|
completed: bool = False
|
|
|
|
|
|
# Properties to receive on todo creation
|
|
class TodoCreate(TodoBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive on todo update
|
|
class TodoUpdate(BaseModel):
|
|
title: Optional[str] = Field(None, min_length=1, max_length=255)
|
|
description: Optional[str] = None
|
|
completed: Optional[bool] = None
|
|
|
|
|
|
# Properties shared by models stored in DB
|
|
class TodoInDBBase(TodoBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Todo(TodoInDBBase):
|
|
pass
|