From bd4a690d953d40ad1989a0e709688ec3c199ff7e Mon Sep 17 00:00:00 2001 From: andrzej Date: Wed, 19 Jun 2024 11:53:35 +0200 Subject: [PATCH] split getStory function it's a waste to be fetching genres unless we're going to use them --- src/app/lib/get.ts | 3 +++ src/app/story/page.tsx | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/lib/get.ts b/src/app/lib/get.ts index 1d9fb8c..85acb76 100644 --- a/src/app/lib/get.ts +++ b/src/app/lib/get.ts @@ -1,6 +1,9 @@ "use server" import prisma from "./db" export async function getStories() { + return prisma.story.findMany() +} +export async function getStoriesWithGenres() { return prisma.story.findMany( { include: { diff --git a/src/app/story/page.tsx b/src/app/story/page.tsx index 7cb6a16..93c0a71 100644 --- a/src/app/story/page.tsx +++ b/src/app/story/page.tsx @@ -1,8 +1,9 @@ import { Story } from "@prisma/client"; import { DataTable } from "./data-table"; import { columns } from "./columns"; -import { getStories } from "app/lib/get"; -const stories: Story[] = await getStories() +import { getStoriesWithGenres } from "app/lib/get"; +import { Genre } from "@prisma/client"; +const stories: Array }> = await getStoriesWithGenres() export default async function Page() { return (