Skip to content

Commit

Permalink
feat: define model class for entity repository
Browse files Browse the repository at this point in the history
  • Loading branch information
italojohnny committed Aug 25, 2024
1 parent 0818d88 commit 69c2b32
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/backend/base/langflow/services/database/models/repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from abc import ABC, abstractmethod
from typing import Generic, TypeVar, List, Optional
from sqlmodel import SQLModel, Session


T = TypeVar("T", bound=SQLModel)


class AbstractRepository(ABC, Generic[T]):
def __init__(self, session: Session):
self.session = session

@abstractmethod
def add(self, entity: T) -> T:
pass

@abstractmethod
def get(self, id: int) -> Optional[T]:
pass

@abstractmethod
def list(self) -> List[T]:
pass

@abstractmethod
def update(self, entity: T) -> T:
pass

@abstractmethod
def delete(self, id: int) -> None:
pass

0 comments on commit 69c2b32

Please sign in to comment.