Files
sign/packages/lib/server-only/document/get-document-by-id.ts

38 lines
673 B
TypeScript
Raw Normal View History

2023-06-09 18:21:18 +10:00
import { prisma } from '@documenso/prisma';
export interface GetDocumentByIdOptions {
id: number;
userId: number;
}
export const getDocumentById = async ({ id, userId }: GetDocumentByIdOptions) => {
return await prisma.document.findFirstOrThrow({
where: {
id,
userId,
2023-12-27 13:04:24 +11:00
OR: [
{
team: {
is: null,
},
},
{
team: {
is: {
members: {
some: {
userId,
},
},
},
},
},
],
2023-06-09 18:21:18 +10:00
},
include: {
documentData: true,
documentMeta: true,
},
2023-06-09 18:21:18 +10:00
});
};