fx
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
Nareshkumar Rao 2025-04-22 12:55:10 +02:00
parent d9e9824146
commit e56bb8ac1c

View File

@ -46,6 +46,7 @@ export async function savePostServer(
if (!post) { if (!post) {
throw new Error("Post not found"); throw new Error("Post not found");
} }
await prisma.post.delete({ where: { slug: existingSlug } });
for (const tag of post.tags) { for (const tag of post.tags) {
const postsWithTag = await prisma.post.count({ const postsWithTag = await prisma.post.count({
where: { tags: { some: { id: tag.id } } }, where: { tags: { some: { id: tag.id } } },
@ -54,7 +55,6 @@ export async function savePostServer(
await prisma.tag.delete({ where: { id: tag.id } }); await prisma.tag.delete({ where: { id: tag.id } });
} }
} }
await prisma.post.delete({ where: { slug: existingSlug } });
} }
await prisma.post.create({ await prisma.post.create({