forked from mtusi2026/mtusi2026lab2
feat-(move2lab2, postgres settings, repo base and other)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from src.models.sessions import Session
|
||||
from src.api.repositories.core import DatabaseManager
|
||||
|
||||
class SessionRepo(DatabaseManager):
|
||||
def __init__(self, session: AsyncSession, model: Session):
|
||||
super().__init__(session, model)
|
||||
|
||||
async def create(self, token_hash: str, user_id: uuid.UUID, expires_at: datetime) -> Optional[Session]:
|
||||
result = await super().create(token_hash=token_hash, user_id=user_id, expires_at=expires_at)
|
||||
return result
|
||||
|
||||
async def get_by_token_hash(self, token_hash: str) -> Optional[Session]:
|
||||
result = await super().get_by_field("token_hash", token_hash)
|
||||
return result
|
||||
|
||||
async def delete_by_token_hash(self, token_hash: str) -> bool:
|
||||
result = await super().delete_by_field("token_hash", token_hash)
|
||||
return result
|
||||
Reference in New Issue
Block a user