© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
2 replies
thebjorn

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')
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
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.
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle Queries in Drizzle Studio
Drizzle TeamDTDrizzle Team / help
3y ago
How to debug Drizzle queries
Drizzle TeamDTDrizzle Team / help
3y ago
Cant get custom type to work with default value
Drizzle TeamDTDrizzle Team / help
16mo ago
Dynamic Drizzle Relational Queries
Drizzle TeamDTDrizzle Team / help
3y ago