Prisma generators are a crucial component of the Prisma ORM (Object-Relational Mapping) system, allowing developers to specify what assets are generated when the prisma generate
command is invoked. This article delves into the world of Prisma generators, exploring their configuration, types, and usage.
A Prisma schema can have one or more generators, represented by the generator
block. The main property provider
defines which Prisma Client (language-specific) is created. Currently, only prisma-client-js
is available. Additionally, you can define a custom output folder for the generated assets using the output
property.
generator client {
provider = "prisma-client-js"
output = "./generated/prisma-client-js"
}
The generator for Prisma's JavaScript Client accepts multiple additional properties, including previewFeatures
and binaryTargets
. previewFeatures
allows you to include preview features, while binaryTargets
specifies the engine binary targets for prisma-client-js
.
generator client {
provider = "prisma-client-js"
previewFeatures = ["sample-preview-feature"]
binaryTargets = ["linux-musl"]
}
Binary targets are used to define which files should be present for the target platform(s). The native
binary target is special, as it detects the current operating system and automatically specifies the correct binary target.
native
binary target is the default and can be set explicitly to include additional binary targets for deployment to different environments.debian-openssl-1.1.x
for Ubuntu 18+ or native
for local development.The Prisma community has created a wide range of generators to extend the functionality of the Prisma ORM. Some examples include:
These community generators can be used to generate various assets, such as API documentation, JSON schema, and CRUD resolvers, making it easier to work with Prisma and improve development productivity.
Prisma generators are a powerful tool for customizing the Prisma ORM and extending its functionality. By understanding how to configure generators and utilizing the wide range of community-generated tools, developers can streamline their development process and improve the overall quality of their applications. For more information on Prisma and its features, visit the official Prisma documentation.
Learn more about Prisma Schema and Prisma Client.
To explore more community generators, check out the Prisma community page.
For any questions or issues, visit the Prisma support page.
To learn about the latest developments and updates, follow Prisma on Twitter.
Read the Prisma blog for the latest articles and tutorials on Prisma and related topics.
Get started with Prisma today and discover how it can help you build scalable and maintainable databases with ease. Sign up for a free account and start exploring the world of Prisma.