"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigRepository = void 0;
const db_1 = require("../db/db");
const schema_1 = require("../db/schema");
const drizzle_orm_1 = require("drizzle-orm");
class ConfigRepository {
    async getValue(key) {
        const drizzle = await db_1.db.getDrizzle();
        const result = await drizzle.select().from(schema_1.config).where((0, drizzle_orm_1.eq)(schema_1.config.key, key)).get();
        return result?.value ?? null;
    }
    async setValue(key, value) {
        const drizzle = await db_1.db.getDrizzle();
        await drizzle.insert(schema_1.config).values({ key, value }).onConflictDoUpdate({
            target: schema_1.config.key,
            set: { value },
        });
    }
    async getAll() {
        const drizzle = await db_1.db.getDrizzle();
        return await drizzle.select().from(schema_1.config).all();
    }
}
exports.ConfigRepository = ConfigRepository;
//# sourceMappingURL=configRepository.js.map