diff --git a/the_app/api/stuff.py b/the_app/api/stuff.py index f23876e..d9c8d7c 100644 --- a/the_app/api/stuff.py +++ b/the_app/api/stuff.py @@ -9,9 +9,10 @@ router = APIRouter() @router.post("/", status_code=status.HTTP_201_CREATED, response_model=StuffResponse) -async def create_stuff(stuff: StuffSchema, db_session: AsyncSession = Depends(get_db)): - stuff_instance = await Stuff.create(db_session, stuff) - return stuff_instance +async def create_stuff(payload: StuffSchema, db_session: AsyncSession = Depends(get_db)): + stuff = Stuff(**payload.dict()) + await stuff.save(db_session) + return stuff @router.get("/", response_model=StuffResponse) diff --git a/the_app/models/stuff.py b/the_app/models/stuff.py index 80aafe6..5b801d6 100644 --- a/the_app/models/stuff.py +++ b/the_app/models/stuff.py @@ -18,15 +18,6 @@ class Stuff(Base): self.name = name self.description = description - @classmethod - async def create(cls, db_session: AsyncSession, schema: StuffSchema): - stuff = Stuff( - name=schema.name, - description=schema.description, - ) - await stuff.save(db_session) - return stuff - async def update(self, db_session: AsyncSession, schema: StuffSchema): self.name = schema.name self.description = schema.description