fix: improve document meta logic

This commit is contained in:
David Nguyen
2024-01-03 20:10:50 +11:00
parent b8a45dd5e3
commit 6be119ac95
2 changed files with 10 additions and 0 deletions

View File

@ -8,6 +8,7 @@ export type CreateDocumentMetaOptions = {
message: string;
timezone: string;
dateFormat: string;
userId: number;
};
export const upsertDocumentMeta = async ({
@ -16,7 +17,15 @@ export const upsertDocumentMeta = async ({
timezone,
dateFormat,
documentId,
userId,
}: CreateDocumentMetaOptions) => {
await prisma.document.findFirstOrThrow({
where: {
id: documentId,
userId,
},
});
return await prisma.documentMeta.upsert({
where: {
documentId,