mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
35 lines
650 B
TypeScript
35 lines
650 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import type { Prisma } from '@documenso/prisma/client';
|
|
|
|
export interface GetTemplateByIdOptions {
|
|
id: number;
|
|
userId: number;
|
|
}
|
|
|
|
export const getTemplateById = async ({ id, userId }: GetTemplateByIdOptions) => {
|
|
const whereFilter: Prisma.TemplateWhereInput = {
|
|
id,
|
|
OR: [
|
|
{
|
|
userId,
|
|
},
|
|
{
|
|
team: {
|
|
members: {
|
|
some: {
|
|
userId,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
return await prisma.template.findFirstOrThrow({
|
|
where: whereFilter,
|
|
include: {
|
|
templateDocumentData: true,
|
|
},
|
|
});
|
|
};
|