Plugin
🔋 ZModel vs Prisma Schema
ZenStack's "plugin" concept replaces PSL's "generator".
Plugin is a powerful mechanism that allows you to extend ZenStack at the schema, CLI, and runtime levels. This section only focuses on how to add plugins to your ZModel. Please refer to the Plugin Development section for more details on how to develop plugins.
Adding plugins to ZModel​
Let's take a look at the following example:
plugin myPlugin {
provider = 'my-zenstack-plugin'
output = './generated'
}
A plugin declaration involves three parts:
- A unique name
- A
provider
field that specifies where to load the plugin from. It can be a built-in plugin (like@core/prisma
here), a local folder, or an npm package. - Plugin-specific configuration options, such as
output
in this case.
A plugin can have the following effects to ZModel:
- It can contribute custom attributes that you can use to annotate models and fields.
- It can contribute code generation logic that's executed when you run the
zenstack generate
command.
Plugins can also contribute to the ORM runtime behavior, and we'll leave it to the ORM part to explain it in detail.