from backend.model.tribe import Tribe from backend.repository.abstract_repository import AbstractRepository class TribeSQLAlchemyRepository(AbstractRepository): def __init__(self, session) -> None: self.session = session def add(self, tribe: Tribe) -> None: self.session.add(tribe) def update(self, name: str, tribe: Tribe) -> None: self.session.query(Tribe).filter_by(name=name).update(tribe.to_dict()) def get(self, name: str) -> Tribe: return self.session.query(Tribe).filter_by(name=name).one() def list(self) -> list[Tribe]: return self.session.query(Tribe).all() def delete(self, tribe: Tribe) -> None: the_tribe = self.get(tribe.name) self.session.delete(the_tribe)