zod-prisma-types icon indicating copy to clipboard operation
zod-prisma-types copied to clipboard

[Feature Request] Generate mappings from model name to schemas

Open CarterRoll opened this issue 9 months ago • 0 comments

I am using this library to do introspection on my Prisma schema dynamically. This almost works, except I have to maintain an object that maps the name of the model to the corresponding schema generated. I have to make one of these for every type of schema generated (optional defaults, scalar fields, relations, etc.). It would be convenient if this library automatically generated those mappings.

As an example, say you have a schema with Users, Posts, and Comments. The generated mappings would look as follows

const ModelToSchema = {
    User: UserSchema,
    Post: PostSchema,
    Comment: CommentSchema
}

const ModelToScalarFieldEnumSchema = {
    User: UserScalarFieldEnumSchema,
    Post: PostScalarFieldEnumSchema,
    Comment: CommentScalarFieldEnumSchema
}

CarterRoll avatar Mar 04 '25 19:03 CarterRoll