dv/backend/shared/base_repository.py

20 lines
496 B
Python

from __future__ import annotations
import uuid
from abc import ABC, abstractmethod
from typing import Generic, TypeVar, Optional
T = TypeVar("T")
class BaseRepository(ABC, Generic[T]):
@abstractmethod
async def find_by_id(self, entity_id: uuid.UUID) -> Optional[T]: ...
@abstractmethod
async def find_all(self) -> list[T]: ...
@abstractmethod
async def save(self, entity: T) -> T: ...
@abstractmethod
async def delete(self, entity_id: uuid.UUID) -> None: ...