"use server";

import { prisma, Prisma, Keyword } from "@repo/db";

export const upsertKeyword = async (
	keyword: Prisma.KeywordCreateInput,
	id?: Keyword["id"],
) => {
	const newKeyword = id
		? await prisma.keyword.update({
				where: { id: id },
				data: keyword,
			})
		: await prisma.keyword.create({ data: keyword });
	return newKeyword;
};

export const deleteKeyword = async (id: Keyword["id"]) => {
	await prisma.keyword.delete({ where: { id: id } });
};
