mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
🚚 Refactor and simplify backend file structure (#609)
This commit is contained in:
committed by
GitHub
parent
a065f9c9e8
commit
73b2884057
@@ -0,0 +1,39 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
# Shared properties
|
||||
class ItemBase(BaseModel):
|
||||
title: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
|
||||
|
||||
# Properties to receive on item creation
|
||||
class ItemCreate(ItemBase):
|
||||
title: str
|
||||
|
||||
|
||||
# Properties to receive on item update
|
||||
class ItemUpdate(ItemBase):
|
||||
pass
|
||||
|
||||
|
||||
# Properties shared by models stored in DB
|
||||
class ItemInDBBase(ItemBase):
|
||||
id: int
|
||||
title: str
|
||||
owner_id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
# Properties to return to client
|
||||
class Item(ItemInDBBase):
|
||||
pass
|
||||
|
||||
|
||||
# Properties properties stored in DB
|
||||
class ItemInDB(ItemInDBBase):
|
||||
pass
|
||||
Reference in New Issue
Block a user