Код: Выделить всё
async def update(
self,
id: Any,
obj_in: UpdateSchemaType
) -> ModelType:
db_obj: ModelType = await self.model.filter(id = id).first()
data_update = jsonable_encoder(obj_in, exclude_unset=True)
db_obj_update = await db_obj.update_from_dict(data_update)
return db_obj_update
Я использую операцию пути с вставкой в fastapi:
Код: Выделить всё
@users_router.put(
'/{user_id}',
name = "Update user"
)
async def update_user(user_id: int, user_update: schemas.UserUpdate):
'Update user'
return await crud.user.update(user_id, user_update)
Подробнее здесь: https://stackoverflow.com/questions/746 ... rtoise-orm