@core/model-meta
The @core/model-meta
plugin generates lightweight metadata for introspecting schema at runtime.
info
This plugin is always automatically included when zenstack generate
is run. You only need to add it to your ZModel if you want to customize its options.
Installation
This plugin is built-in to ZenStack and does not need to be installed separately.
Options
Name | Type | Description | Required | Default |
---|---|---|---|---|
output | String | Output directory (relative to the path of ZModel) | No | node_modules/.zenstack |
compile | Boolean | If the generated TS code should be compiled to JS | No | true |
preserveTsFiles | Boolean | If the generated TS files should be preserved (after compiled to JS) | No | true if compile is set to false, otherwise false |
Example
/schema.zmodel
plugin meta {
provider = '@core/model-meta'
output = 'src/lib/zenstack'
compile = false
}
Runtime APIs like enhance
and withPolicy
depend on the output of this plugin and by default load it from the default output location. If you customize the output location, you need to load and pass it manually:
const meta = require('./lib/zenstack/model-meta').default;
const db = enhance(prisma, { user }, undefined, meta);