mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
48 lines
761 B
TypeScript
48 lines
761 B
TypeScript
'use server';
|
|
|
|
import { prisma } from '@documenso/prisma';
|
|
|
|
export type CreateDocumentMetaOptions = {
|
|
documentId: number;
|
|
subject: string;
|
|
message: string;
|
|
timezone: string;
|
|
dateFormat: string;
|
|
userId: number;
|
|
};
|
|
|
|
export const upsertDocumentMeta = async ({
|
|
subject,
|
|
message,
|
|
timezone,
|
|
dateFormat,
|
|
documentId,
|
|
userId,
|
|
}: CreateDocumentMetaOptions) => {
|
|
await prisma.document.findFirstOrThrow({
|
|
where: {
|
|
id: documentId,
|
|
userId,
|
|
},
|
|
});
|
|
|
|
return await prisma.documentMeta.upsert({
|
|
where: {
|
|
documentId,
|
|
},
|
|
create: {
|
|
subject,
|
|
message,
|
|
dateFormat,
|
|
timezone,
|
|
documentId,
|
|
},
|
|
update: {
|
|
subject,
|
|
message,
|
|
dateFormat,
|
|
timezone,
|
|
},
|
|
});
|
|
};
|