© 2026 Hedgehog Software, LLC

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

Type Hinting $inferSelect

Hi Drizzle Team,

I have the following tables set up with Postgres and Drizzle. There is a
reviews
reviews
table with an enum
status
status
field. When the
status
status
is
assigned
assigned
, the
userId
userId
field is non-null, otherwise it's null.

Is there a way to typehint
reviews.$inferSelect
reviews.$inferSelect
such that it adheres to the type logic above?

export const status = pgEnum("status", ["unassigned", "assigned"]);
export const reviews = createTable("review", {
  id: uuid("id").defaultRandom().primaryKey(),
  status: status("status").notNull(),
  userId: uuid("user_id"), // set if the review status is 'assigned'
});
export const status = pgEnum("status", ["unassigned", "assigned"]);
export const reviews = createTable("review", {
  id: uuid("id").defaultRandom().primaryKey(),
  status: status("status").notNull(),
  userId: uuid("user_id"), // set if the review status is 'assigned'
});
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

View No $inferSelect
Drizzle TeamDTDrizzle Team / help
17mo ago
.$inferSelect for relations
Drizzle TeamDTDrizzle Team / help
3y ago
Omit fields on "$inferSelect"?
Drizzle TeamDTDrizzle Team / help
3y ago
Way to get relations via typeof someSchema.$inferSelect?
Drizzle TeamDTDrizzle Team / help
2y ago