mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
22 lines
455 B
TypeScript
22 lines
455 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
export type GetRecipientByEmailOptions = {
|
|
documentId: number;
|
|
email: string;
|
|
};
|
|
|
|
export const getRecipientByEmail = async ({ documentId, email }: GetRecipientByEmailOptions) => {
|
|
const recipient = await prisma.recipient.findFirst({
|
|
where: {
|
|
documentId,
|
|
email: email.toLowerCase(),
|
|
},
|
|
});
|
|
|
|
if (!recipient) {
|
|
throw new Error('Recipient not found');
|
|
}
|
|
|
|
return recipient;
|
|
};
|