kalissaac / prisma-typegen Goto Github PK
View Code? Open in Web Editor NEWGenerates full types (including relations) for TypeScript from a Prisma schema
License: MIT License
Generates full types (including relations) for TypeScript from a Prisma schema
License: MIT License
Hey @Kalissaac !
I stumbled upon this package the other day, and it fits my use case very well, with only one small hang up. I'm using prisma-typegen to create a library of interfaces that are imported by several micro-services. I have several fields in my schema.prisma file (such as id
and created_at
) that have default values, usually a database function. Because I'm relying on database functions instead TS code to populate these fields, I think it would make sense to have prisma-typegen only mark fields without a default value as being required.
I've already implemented a quick fix for this:
This line should instead read required: f.isRequired && !f.hasDefaultValue,
.
I could see enabling this behavior as an option if you're assigning the generated interface to a row already in the database, but for a case like mine where I'm assigning the interface to data get to be inserted, this change makes a lot of sense.
Thanks for reading!
The name of the file is "index.ts" by default, can it have another name?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.