© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2mo ago•
2 replies
YK

Getting Type Error With Drizzle Relational Query

node-postgresdrizzle ormPostgreSQL
Hoping someone can share some insight on a type error. I am getting an error when using relational query, it is giving and error of

Property 'userTable' does not exist on type '{}'.
Property 'userTable' does not exist on type '{}'.


drizzle-orm:
^1.0.0-beta.8-734e789
^1.0.0-beta.8-734e789

next js:
16.1
16.1


GitHub Bug: https://github.com/drizzle-team/drizzle-orm/issues/5213

I have the following database configuration

import { drizzle } from "drizzle-orm/node-postgres";
import { Client, Pool } from "pg";
import PostgreSQLConfiguration from "@/configuration/database";
import * as schema from "./schema";

const DATABASE_URI = PostgreSQLConfiguration.DATABASE_URI;
// console.debug(`Database URI: ${DATABASE_URI}`);

const pgClient = new Client({
  connectionString: DATABASE_URI,
});

const pgPool = new Pool({
  connectionString: DATABASE_URI,
  max: 5,
})

export const drizzleClient = drizzle({
  client: pgPool,
  schema: schema,
  logger: true,
});

const executeResult = await drizzleClient.query.userTable.findMany();
console.debug("Execute Result:", executeResult);

export { pgClient, pgPool };
export type drizzleClient = typeof drizzleClient;
export default drizzleClient;
import { drizzle } from "drizzle-orm/node-postgres";
import { Client, Pool } from "pg";
import PostgreSQLConfiguration from "@/configuration/database";
import * as schema from "./schema";

const DATABASE_URI = PostgreSQLConfiguration.DATABASE_URI;
// console.debug(`Database URI: ${DATABASE_URI}`);

const pgClient = new Client({
  connectionString: DATABASE_URI,
});

const pgPool = new Pool({
  connectionString: DATABASE_URI,
  max: 5,
})

export const drizzleClient = drizzle({
  client: pgPool,
  schema: schema,
  logger: true,
});

const executeResult = await drizzleClient.query.userTable.findMany();
console.debug("Execute Result:", executeResult);

export { pgClient, pgPool };
export type drizzleClient = typeof drizzleClient;
export default drizzleClient;


the user schema (
database/schema/user.ts
database/schema/user.ts
) look something like this

import { defineRelations, sql } from "drizzle-orm";
import { pgTable, text, uuid } from "drizzle-orm/pg-core";
import { TABLE_PREFIX } from "@/configuration/database";

const userTable = pgTable(`${TABLE_PREFIX}user`, {
  ...
});

const userRelationList = defineRelations(
  ...
);

export default userTable;
export { userRelationList, userTable };
import { defineRelations, sql } from "drizzle-orm";
import { pgTable, text, uuid } from "drizzle-orm/pg-core";
import { TABLE_PREFIX } from "@/configuration/database";

const userTable = pgTable(`${TABLE_PREFIX}user`, {
  ...
});

const userRelationList = defineRelations(
  ...
);

export default userTable;
export { userRelationList, userTable };


it is exported via an index (
database/schema/index.ts
database/schema/index.ts
)

export * from "./user";
export * from "./user";
GitHub
[BUG]: Type Error With Relational Query With Next.js · Issue #5213...
Report hasn't been filed before. I have verified that the bug I'm about to report hasn't been filed before. What version of drizzle-orm are you using? ^1.0.0-beta.8-734e789 What version...
[BUG]: Type Error With Relational Query With Next.js · Issue #5213...
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Drizzle relational query, filters
Drizzle TeamDTDrizzle Team / help
3y ago
Proper type for relational query
Drizzle TeamDTDrizzle Team / help
11mo ago
Infer type for relational query
Drizzle TeamDTDrizzle Team / help
3y ago
Infer return type for relational query with pagination
Drizzle TeamDTDrizzle Team / help
3y ago