Commit 9fb7d1c5 authored by OliviaLivak's avatar OliviaLivak
Browse files

Criação dos métodos update e delete do account

parent be899629
Showing with 16 additions and 2 deletions
+16 -2
......@@ -4,6 +4,8 @@ from sqlalchemy.dialects.postgresql import insert
from app.config.database import get_db
from sqlalchemy import select
from starlette import status
from sqlalchemy import update
from sqlalchemy import delete
from uuid import uuid4
from app.schemas.accounts import AccountRequest
......@@ -37,10 +39,22 @@ class AccountsService:
return result.scalar_one()
async def update_account(self, account_id: str, account: AccountRequest):
raise NotImplementedError()
result = await self.__session.execute(
update(Account).where(Account.id == account_id)
.values(name=account.name)
.returning(Account)
)
await self.__session.commit()
return result.scalar_one()
async def delete_account(self, account_id: str):
raise NotImplementedError()
result = await self.__session.execute(
delete(Account).where(Account.id == account_id)
)
await self.__session.commit()
@classmethod
async def get_service(cls, db: AsyncSession = Depends(get_db)):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment