Files
documenso/packages/lib/server-only/attachment/find-attachments.ts
2025-07-07 12:04:20 +03:00

23 lines
518 B
TypeScript

import { prisma } from '@documenso/prisma';
import { buildTeamWhereQuery } from '../../utils/teams';
export type FindAttachmentsOptions = {
documentId: number;
userId: number;
teamId: number;
};
export const findAttachments = async ({ documentId, userId, teamId }: FindAttachmentsOptions) => {
const attachments = await prisma.attachment.findMany({
where: {
document: {
id: documentId,
team: buildTeamWhereQuery({ teamId, userId }),
},
},
});
return attachments;
};