27 lines
573 B
TypeScript
27 lines
573 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export async function POST() {
|
|
try {
|
|
const result = await prisma.transaction.updateMany({
|
|
where: {
|
|
categoryId: { not: null },
|
|
},
|
|
data: {
|
|
categoryId: null,
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
count: result.count,
|
|
});
|
|
} catch (error) {
|
|
console.error("Error clearing categories:", error);
|
|
return NextResponse.json(
|
|
{ error: "Failed to clear categories" },
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
}
|