| @@ -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({ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user