How to Reference a Column Type in Drizzle

Hi everyone! I used to work with Prisma, and now I've started learning Drizzle. I have a problem: is it possible to reference the type of a specific column in a table? If so, how? In Prisma, I solved it like this: import { Pet } from '@prisma/client'; selectedID: Pet['id'] | null; However, this approach doesn't work in Drizzle, and I get the following error: 'verificationTokens' refers to a value, but is being used as a type here. Did you mean 'typeof verificationTokens'? I tried with typeof but it did not work. Here is my code: import { users, verificationTokens } from '@/db/schema'; type VerificationType = { email: verificationTokens['email']; token: verificationTokens['token']; }; Thanks in advance for the help.
No description
3 Replies
rphlmr âš¡
rphlmr ⚡•6mo ago
👋 Welcome! Maybe you are looking for https://orm.drizzle.team/docs/goodies#type-api ?
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
rphlmr âš¡
rphlmr ⚡•6mo ago
type VerificationTokens = typeof verificationTokens.$inferSelect;
type VerificationTokens = typeof verificationTokens.$inferSelect;
Ganbatte
GanbatteOP•6mo ago
oh yes, Thank you so much!
Want results from more Discord servers?
Add your server