mbe
mbe
Explore posts from servers
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
hello everyone i am having some problems doing a one to many relation and select on a post schema i have. for context i get this error when ever i try to make a query using the where and with
Internal error: TypeError: Cannot read properties of undefined (reading 'referencedTable')
Internal error: TypeError: Cannot read properties of undefined (reading 'referencedTable')
here is my select statement
const post = await database.query.posts.findFirst({
where: eq(posts.id, params.postId),
with: {
tags: true,
links: true,
},
});
const post = await database.query.posts.findFirst({
where: eq(posts.id, params.postId),
with: {
tags: true,
links: true,
},
});
and here is my schema:
13 replies
DTDrizzle Team
Created by mbe on 7/21/2024 in #help
how to use booleans in dizzle?
i have succesfully followed the drizzle docs on how to use booleans but i get a weird error: Type 'MySqlBooleanBuilderInitial<"isFeatured">' is not assignable to type 'PgColumnBuilderBase<ColumnBuilderBaseConfig<ColumnDataType, string>, object>'. The types of '_.dialect' are incompatible between these types. Type '"mysql"' is not assignable to type '"pg"'.ts(2322) here is my table: export const articles = pgTable("p_articles", { id: serial("id").primaryKey(), userId: text("userId") .notNull() .references(() => users.id, { onDelete: "cascade" }), title: text("title").notNull(), description: text("description").notNull(), isFeatured: boolean("isFeatured"), imageUrl: text("imageUrl").notNull(), createdDate: timestamp("timestamp", { mode: "date" }).notNull(), });
3 replies
DTDrizzle Team
Created by mbe on 6/1/2024 in #help
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> ); }
3 replies
DTDrizzle Team
Created by mbe on 5/30/2024 in #help
unable to run drizzle studio
No description
12 replies