mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 12:32:34 +10:00
26 lines
452 B
TypeScript
26 lines
452 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
export type DeleteUserOptions = {
|
|
email: string;
|
|
};
|
|
|
|
export const deleteUser = async ({ email }: DeleteUserOptions) => {
|
|
const user = await prisma.user.findFirst({
|
|
where: {
|
|
email: {
|
|
contains: email,
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!user) {
|
|
throw new Error(`User with email ${email} not found`);
|
|
}
|
|
|
|
return await prisma.user.delete({
|
|
where: {
|
|
id: user.id,
|
|
},
|
|
});
|
|
};
|