Error: Cannot read properties of undefined (reading 'findMany')

import { auth } from "@/auth"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { SignIn } from "@/components/ui/signin"; import { SignOut } from "@/components/ui/signout"; import { database } from "@/db/database"; import { items } from "@/db/schema"; import { revalidatePath } from "next/cache"; export default async function Home() { const session = await auth(); const allItems = await database.query.items.findMany(); if (!session) { return <SignIn />; } const user = session.user; if (!user) { return <SignIn />; } return ( <main className="container mx-auto py-12"> {session ? <SignOut /> : <SignIn />} <form action={async (formData: FormData) => { "use server"; await database.insert(items).values({ name: formData.get("name") as string, userId: session?.user?.id!, }); revalidatePath("/"); }} > <Input name="name" placeholder="name your item" /> <Button type="submit">post item</Button> {allItems.map((item) => ( <div key={item.id}>{item.name}</div> ))} </form> </main> ); }
1 Reply
mbe52are_93191
mbe52are_931914mo ago
here is my schema where i create my items: export const items = pgTable("bb_item", { id: serial("id").primaryKey(), userId: text("userId") .notNull() .references(() => users.id, { onDelete: "cascade" }), name: text("name").notNull(), }); anyway my question is why is items undefined in the findmany? i can easily fetch other things like bids,accounts etc.
Want results from more Discord servers?
Add your server