from core.database.abc.db_model_dao_abc import DbModelDaoABC
from core.logger import DBLogger
from data.schemas.system.setting import Setting

logger = DBLogger(__name__)


class SettingDao(DbModelDaoABC[Setting]):

    def __init__(self):
        DbModelDaoABC.__init__(self, __name__, Setting, "system.settings")

        self.attribute(Setting.key, str)
        self.attribute(Setting.value, str)

    async def find_by_key(self, key: str) -> Setting:
        return await self.find_single_by({Setting.key: key})


settingDao = SettingDao()
