32 lines
689 B
Python
32 lines
689 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
# Shared properties
|
|
class TodoBase(BaseModel):
|
|
title: str
|
|
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(TodoBase):
|
|
title: 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:
|
|
from_attributes = True
|
|
|
|
# Properties to return to client
|
|
class Todo(TodoInDBBase):
|
|
pass |