This commit is contained in:
Timur Ercan
2023-02-14 11:12:07 +01:00
parent a43c1f7a91
commit 3d9bf1fb67
2 changed files with 14 additions and 12 deletions

View File

@ -114,20 +114,22 @@ export async function getServerSideProps(context: any) {
const { id: documentId } = context.query;
try {
const document: PrismaDocument = await getDocument(
+documentId,
context.req,
context.res
);
// todo optimize querys
// todo no intersection groups
} catch (error) {
if (!document) {
return {
notFound: true,
};
}
}
// todo optimize querys
// todo no intersection groups
return {
props: {

View File

@ -12,7 +12,7 @@ export const getDocument = async (
if (!documentId) Promise.reject("No documentId");
if (!req || !res) Promise.reject("No res or req");
const document: PrismaDocument = await prisma.document.findFirst({
const document: PrismaDocument = await prisma.document.findFirstOrThrow({
where: {
id: documentId,
userId: user.id,