From 5dd109bdc83361233aa9ba6cd1deb5fa27c50c6a Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Mon, 11 Jul 2022 10:05:42 -0600 Subject: [PATCH] select only what is used --- app/models/note.server.ts | 1 + app/routes/notes/$noteId.tsx | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/note.server.ts b/app/models/note.server.ts index ba56b532..c266dfc0 100644 --- a/app/models/note.server.ts +++ b/app/models/note.server.ts @@ -11,6 +11,7 @@ export function getNote({ userId: User["id"]; }) { return prisma.note.findFirst({ + select: { id: true, body: true, title: true }, where: { id, userId }, }); } diff --git a/app/routes/notes/$noteId.tsx b/app/routes/notes/$noteId.tsx index fe5ee262..4800b176 100644 --- a/app/routes/notes/$noteId.tsx +++ b/app/routes/notes/$noteId.tsx @@ -3,13 +3,12 @@ import { json, redirect } from "@remix-run/node"; import { Form, useCatch, useLoaderData } from "@remix-run/react"; import invariant from "tiny-invariant"; -import type { Note } from "~/models/note.server"; import { deleteNote } from "~/models/note.server"; import { getNote } from "~/models/note.server"; import { requireUserId } from "~/session.server"; type LoaderData = { - note: Note; + note: NonNullable>>; }; export const loader: LoaderFunction = async ({ request, params }) => {