mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
36 lines
655 B
TypeScript
36 lines
655 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
export interface GetFieldsForTemplateOptions {
|
|
templateId: number;
|
|
userId: number;
|
|
}
|
|
|
|
export const getFieldsForTemplate = async ({ templateId, userId }: GetFieldsForTemplateOptions) => {
|
|
const fields = await prisma.field.findMany({
|
|
where: {
|
|
templateId,
|
|
Template: {
|
|
OR: [
|
|
{
|
|
userId,
|
|
},
|
|
{
|
|
team: {
|
|
members: {
|
|
some: {
|
|
userId,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
orderBy: {
|
|
id: 'asc',
|
|
},
|
|
});
|
|
|
|
return fields;
|
|
};
|