from core.database.abc.db_model_dao_abc import DbModelDaoABC
from core.logger import DBLogger
from data.schemas.system.feature_flag import FeatureFlag

logger = DBLogger(__name__)


class FeatureFlagDao(DbModelDaoABC[FeatureFlag]):

    def __init__(self):
        DbModelDaoABC.__init__(self, __name__, FeatureFlag, "system.feature_flags")

        self.attribute(FeatureFlag.key, str)
        self.attribute(FeatureFlag.value, bool)

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


featureFlagDao = FeatureFlagDao()
