Rafael
Rafael
DTDrizzle Team
Created by Gabriel Lucena on 1/20/2024 in #help
help with drizzle-zod with jsonb column
But you can override it
const addressSchema = z.object({
...
})

type Address = z.infer<typeof addressSchema>

const tableSchema = createInsertSchema(customerTable, {
addresses: z.array(addressSchema)
})

export type Customer = z.infer<typeof tableSchema>
const addressSchema = z.object({
...
})

type Address = z.infer<typeof addressSchema>

const tableSchema = createInsertSchema(customerTable, {
addresses: z.array(addressSchema)
})

export type Customer = z.infer<typeof tableSchema>
4 replies
DTDrizzle Team
Created by Gabriel Lucena on 1/20/2024 in #help
help with drizzle-zod with jsonb column
It can't do that, the library and Zod only know about concrete information, and types aren't concrete. The only concrete information is Json. For custom columns, it uses z.any (https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-zod/src/index.ts#L205).
4 replies