drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[FEATURE]: Export factory functions from `drizzle-zod` to allow usage with extended Zod classes

Open juliusmarminge opened this issue 1 year ago • 3 comments

Describe what you want

To allow generating schemas from an extended Zod class, such as: https://github.com/honojs/middleware/tree/main/packages/zod-openapi

Currently, this doesn't work since generated schemas are using the default z object which will cause runtime errors if later combined with .openapi() from the lib above

Something like this would be nice

import { z } from '@hono/zod-openapi'
import { createInsertSchemaFactory } from 'drizzle-zod/factories'

import { User } from '~/schema'

const createInsertSchema = createInsertSchemaFactory(z);

const InsertUser = createInsertSchema(User)

// later

InsertUser.openapi() // works

juliusmarminge avatar May 02 '24 11:05 juliusmarminge

This would be very helpful. I don't understand how people use Hono with Drizzle without this, is everyone duplicating their source of truth?

d4mr avatar May 12 '24 11:05 d4mr

Really need this +1

Marley-Mulvin-Broome avatar Jun 29 '24 03:06 Marley-Mulvin-Broome

Hey, any known workarounds for this so far? Specifically when using with zod-openapi?

thatvertigo avatar Aug 05 '24 14:08 thatvertigo

Need this as well. Hope this can get implemented.

Flesky avatar Aug 27 '24 20:08 Flesky

that would be very nice!

PedroClerici avatar Sep 10 '24 22:09 PedroClerici