from sqlalchemy.orm import Session
from app.model.lovelace_url_model import LovelaceURL


class LovelaceURLDAO:
    def __init__(self, db_session: Session):
        self.db_session = db_session

    def get_all(self):
        return self.db_session.query(LovelaceURL).all()

    def get_by_id(self, record_id: int):
        return self.db_session.query(LovelaceURL).get(record_id)

    def create(self, record: LovelaceURL):
        self.db_session.add(record)
        self.db_session.commit()
        return record

    def update(self, record: LovelaceURL):
        self.db_session.commit()
        return record

    def delete(self, record: LovelaceURL):
        self.db_session.delete(record)
        self.db_session.commit()


