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.3 Replies
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
oh yes, Thank you so much!