Add POST endpoint for /db-endpoint

This commit is contained in:
Backend IM Bot 2025-03-26 02:37:48 +00:00
parent 1f0c94c0b5
commit 64848f2488

View File

@ -10,10 +10,10 @@ router = APIRouter()
@router.post("/db-endpoint", status_code=201, response_model=FruitSchema) @router.post("/db-endpoint", status_code=201, response_model=FruitSchema)
async def create_fruit( async def create_fruit(
fruit_data: FruitCreate, fruit: FruitCreate,
db: Session = Depends(get_db) db: Session = Depends(get_db)
): ):
new_fruit = Fruit(name=fruit_data.name) new_fruit = Fruit(name=fruit.name)
db.add(new_fruit) db.add(new_fruit)
db.commit() db.commit()
db.refresh(new_fruit) db.refresh(new_fruit)