38 lines
673 B
Python
38 lines
673 B
Python
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class CategoryBase(BaseModel):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
|
|
|
|
# Properties to receive on category creation
|
|
class CategoryCreate(CategoryBase):
|
|
name: str
|
|
|
|
|
|
# Properties to receive on category update
|
|
class CategoryUpdate(CategoryBase):
|
|
pass
|
|
|
|
|
|
# Properties shared by models in DB
|
|
class CategoryInDBBase(CategoryBase):
|
|
id: int
|
|
name: str
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Properties to return to client
|
|
class Category(CategoryInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties stored in DB
|
|
class CategoryInDB(CategoryInDBBase):
|
|
pass |