Full crud with the C

This commit is contained in:
2023-01-18 13:47:00 +01:00
parent a7aae397ca
commit 6ccbb8ac00
4 changed files with 31 additions and 12 deletions

View File

@@ -38,7 +38,7 @@ def get_crud_router(model, model_create, model_read, model_update):
async def create(item: model_create) -> dict:
await item.validate_foreign_key()
o = await model(**item.dict()).create()
return {"message": "{} added successfully".format(model.__name__), "id": o}
return {"message": "{} added successfully".format(model.__name__), "id": o.id}
@router.get("/{id}", response_description="{} record retrieved".format(model.__name__))
async def read_id(id: PydanticObjectId) -> model_read: