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(),
})


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

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
Was this page helpful?