subman-nextjs/src/app/lib/del.ts

22 lines
516 B
TypeScript
Raw Normal View History

"use server"
2024-06-19 17:46:30 +00:00
import { revalidatePath } from "next/cache";
import prisma from "./db";
2024-06-19 17:46:30 +00:00
import { redirect } from "next/navigation";
2024-06-19 17:46:30 +00:00
export async function deleteStory(id: number) {
const res = await prisma.story.delete({
where: { id }
})
2024-06-19 17:46:30 +00:00
console.log(`deleted: ${res}`)
revalidatePath("/story")
redirect("/story")
}
2024-06-20 08:35:25 +00:00
export async function deletePub(id: number) {
const res = await prisma.pub.delete({
where: { id }
})
console.log(`deleted: ${res}`)
revalidatePath("/publication")
redirect("/publication")
}