import prisma from '../database.js';

export async function getSetting(key) 
{
  const setting = await prisma.setting.findUnique({
    where: { key },
    select: { value: true }
  });
    
  return setting?.value ? JSON.parse(setting.value) : null;
}

export async function setSetting(key, value) 
{
  await prisma.setting.upsert({
    where: { key },
    update: { value: JSON.stringify(value) },
    create: { key, value }
  });
}