© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
5 replies
jakeleventhal

Is there a better way to access enum types?

// the schema
export const MarketplaceIntegrationType = pgEnum('MarketplaceIntegrationType', [
  'Amazon',
  'Walmart',
  'Etsy',
  'Shopify'
]);
type: MarketplaceIntegrationType('type').notNull()

// the code
let integrationType: typeof marketplaceIntegrations.$inferSelect.type;
// the schema
export const MarketplaceIntegrationType = pgEnum('MarketplaceIntegrationType', [
  'Amazon',
  'Walmart',
  'Etsy',
  'Shopify'
]);
type: MarketplaceIntegrationType('type').notNull()

// the code
let integrationType: typeof marketplaceIntegrations.$inferSelect.type;

is there a better way to do this other than manually creating a type to use everywhere? its not very ergonomic to type this out like that

i can also do something like
(typeof MarketplaceIntegrationType.enumValues)[number]
(typeof MarketplaceIntegrationType.enumValues)[number]

but this sucks too
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

Is there a way I can use relational types?
Drizzle TeamDTDrizzle Team / help
3y ago
Is there a way to define "nullable" types for magic SQL?
Drizzle TeamDTDrizzle Team / help
2y ago
Is there a better way to extract Typescript types for use in function args than what I'm doing here?
Drizzle TeamDTDrizzle Team / help
3y ago
Is there a simpler way to get an enum type than (typeof enumType)["enumValues"][number]?
Drizzle TeamDTDrizzle Team / help
3y ago