mirror of
https://github.com/RYDE-WORK/full-stack-fastapi-template.git
synced 2026-01-27 01:03:43 +08:00
* Update CRUD utils to use types better. * Simplify Pydantic model names, from `UserInCreate` to `UserCreate`, etc. * Upgrade packages. * Add new generic "Items" models, crud utils, endpoints, and tests. To facilitate re-using them to create new functionality. As they are simple and generic (not like Users), it's easier to copy-paste and adapt them to each use case. * Update endpoints/*path operations* to simplify code and use new utilities, prefix and tags in `include_router`. * Update testing utils. * Update linting rules, relax vulture to reduce false positives. * Update migrations to include new Items. * Update project README.md with tips about how to start with backend.
35 lines
562 B
Python
35 lines
562 B
Python
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class ItemBase(BaseModel):
|
|
title: str = None
|
|
description: 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
|
|
|
|
|
|
# Properties to return to client
|
|
class Item(ItemInDBBase):
|
|
pass
|
|
|
|
|
|
# Properties properties stored in DB
|
|
class ItemInDB(ItemInDBBase):
|
|
pass
|