Files

15 lines
497 B
TypeScript

import { prisma } from "./db";
import { deleteUploadsForDraft } from "./uploads/deleteUploadedFiles";
/** Remove the signed-in user's in-progress draft and any files still tied to it. */
export async function deleteRuleDraftForUser(userId: string): Promise<void> {
const draft = await prisma.ruleDraft.findUnique({
where: { userId },
select: { id: true },
});
if (draft) {
await deleteUploadsForDraft(draft.id);
}
await prisma.ruleDraft.deleteMany({ where: { userId } });
}