{post.content ? (
{post.content}
) : (
-
+
No content available for this post.
)}
diff --git a/examples/prisma-postgres/app/posts/new/page.tsx b/examples/prisma-postgres/app/posts/new/page.tsx
index 0093ae98ea1ab..2253e0b975f6e 100644
--- a/examples/prisma-postgres/app/posts/new/page.tsx
+++ b/examples/prisma-postgres/app/posts/new/page.tsx
@@ -13,23 +13,18 @@ export default function NewPost() {
const title = formData.get("title") as string;
const content = formData.get("content") as string;
- const postData = authorEmail
- ? {
- title,
- content,
- author: {
- connect: {
- email: authorEmail,
- },
- },
- }
- : {
- title,
- content,
- };
+ if (!authorEmail) {
+ throw new Error("Author email is required");
+ }
await prisma.post.create({
- data: postData,
+ data: {
+ title,
+ content,
+ author: {
+ connect: { email: authorEmail },
+ },
+ },
});
revalidatePath("/posts");
@@ -38,7 +33,9 @@ export default function NewPost() {
return (
-
Create New Post
+
+ Create New Post
+