DT
Drizzle Team•6mo ago
Slaven

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
}
2 Replies
Want results from more Discord servers?
Add your server