Slaven
Slaven
Explore posts from servers
DTDrizzle Team
Created by Slaven on 5/13/2024 in #help
Table definition to TS type
Is it possible to get a TS type from a Drizzle Schema Table definition? Something like this:
export const users = pgTable('user', {
id: text('id')
.primaryKey()
.$default(() => `${Math.random()}`),
name: text('name'),
email: text('email').notNull(),
emailVerified: timestamp('emailVerified', { mode: 'date' }),
image: text('image')
})
export const users = pgTable('user', {
id: text('id')
.primaryKey()
.$default(() => `${Math.random()}`),
name: text('name'),
email: text('email').notNull(),
emailVerified: timestamp('emailVerified', { mode: 'date' }),
image: text('image')
})
👆 would convert to 👇
type User = {
id: string
name: string
email: string
emailVerified: string
image: string
}
type User = {
id: string
name: string
email: string
emailVerified: string
image: string
}
3 replies