28 lines
686 B
TypeScript
28 lines
686 B
TypeScript
"use server";
|
|
|
|
import { prisma, Prisma, Changelog } from "@repo/db";
|
|
export const upsertChangelog = async (
|
|
changelog: Prisma.ChangelogCreateInput,
|
|
id?: Changelog["id"],
|
|
) => {
|
|
const newChangelog = id
|
|
? await prisma.changelog.update({
|
|
where: { id: id },
|
|
data: changelog,
|
|
})
|
|
: await prisma.$transaction(async (prisma) => {
|
|
const createdChangelog = await prisma.changelog.create({ data: changelog });
|
|
|
|
await prisma.user.updateMany({
|
|
data: { changelogAck: false },
|
|
});
|
|
|
|
return createdChangelog;
|
|
});
|
|
return newChangelog;
|
|
};
|
|
|
|
export const deleteChangelog = async (id: Changelog["id"]) => {
|
|
await prisma.changelog.delete({ where: { id: id } });
|
|
};
|