© 2026 Hedgehog Software, LLC

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

help with drizzle-zod with jsonb column

I have this table definition:

interface Address {
  street: string
  number: string
  complement: string
  neighborhood: string
  city: string
  state: string
  zipcode: string
}

export const customerTable = pgTable("customer", {
  id: text("id").primaryKey(),
  userId: text("user_id")
    .notNull()
    .references(() => userTable.id),
  addresses: jsonb("addresses").$type<Address[]>().notNull(),
})
interface Address {
  street: string
  number: string
  complement: string
  neighborhood: string
  city: string
  state: string
  zipcode: string
}

export const customerTable = pgTable("customer", {
  id: text("id").primaryKey(),
  userId: text("user_id")
    .notNull()
    .references(() => userTable.id),
  addresses: jsonb("addresses").$type<Address[]>().notNull(),
})


then I use drizzle-zod to create a type from that schema:

const tableSchema = createInsertSchema(customerTable)

export type Customer = z.infer<typeof tableSchema>
const tableSchema = createInsertSchema(customerTable)

export type Customer = z.infer<typeof tableSchema>


but the addresses property is a json type, not an array of Address.

Is there a way to change that behavior?
image.png
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

Help with Drizzle-zod
Drizzle TeamDTDrizzle Team / help
3y ago
drizzle-zod not infering jsonb type properly
Drizzle TeamDTDrizzle Team / help
2y ago
Drizzle Studio jsonb column showing [object Object]
Drizzle TeamDTDrizzle Team / help
7mo ago
Help, Partial select with drizzle-zod
Drizzle TeamDTDrizzle Team / help
2y ago