thebjorn
thebjorn
Explore posts from servers
DTDrizzle Team
Created by thebjorn on 6/4/2024 in #help
I cant get Drizzle with Queries to work...
I'm converting a project from prisma, and I'm a bit stuck on the simplest of queries... This returns records:
await db.query.Session.findMany({})
await db.query.Session.findMany({})
while this:
await db.query.Session.findMany({
with: {User: true}
})
await db.query.Session.findMany({
with: {User: true}
})
throws TypeError: Cannot read properties of undefined (reading 'referencedTable') The Session table:
export const Session = pgTable("Session", {
sessionToken: text("sessionToken").notNull(),
userId: text("userId").notNull().references(() => User.id, { onDelete: "cascade", onUpdate: "cascade" } ),...
export const Session = pgTable("Session", {
sessionToken: text("sessionToken").notNull(),
userId: text("userId").notNull().references(() => User.id, { onDelete: "cascade", onUpdate: "cascade" } ),...
The User table:
export const User = pgTable("User", {
id: text("id").primaryKey().notNull(),
...
export const User = pgTable("User", {
id: text("id").primaryKey().notNull(),
...
(there was also a relations.ts file created during introspection that is not imported anywhere) I'm sure I've just missed something in the documentation, but I've been stuck on this for almost a day now.
3 replies