Add POST endpoint for /db-endpoint
This commit is contained in:
parent
1f0c94c0b5
commit
64848f2488
@ -10,10 +10,10 @@ router = APIRouter()
|
||||
|
||||
@router.post("/db-endpoint", status_code=201, response_model=FruitSchema)
|
||||
async def create_fruit(
|
||||
fruit_data: FruitCreate,
|
||||
fruit: FruitCreate,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
new_fruit = Fruit(name=fruit_data.name)
|
||||
new_fruit = Fruit(name=fruit.name)
|
||||
db.add(new_fruit)
|
||||
db.commit()
|
||||
db.refresh(new_fruit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user