File tree 4 files changed +34
-57
lines changed
4 files changed +34
-57
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,23 @@ Ref: Post.authorId > User.id
105
105
106
106
4 . [ Visualize] ( https://dbdiagram.io/d ) the ` schema.dbml `
107
107
108
+ ## Additional Options
109
+
110
+ | Option | Description | Type | Default |
111
+ | ------------ | ---------------------------------- | -------- | ------------- |
112
+ | ` output ` | Output directory for the DBML file | ` string ` | ` ./dbml ` |
113
+ | ` outputName ` | Name for the DBML file | ` string ` | ` dbml.schema ` |
114
+
115
+ Use additional options in the ` prisma.schema `
116
+
117
+ ``` prisma
118
+ generator dbml {
119
+ provider = "prisma-dbml-generator"
120
+ output = "../dbml"
121
+ outputName = "awesome.dbml"
122
+ }
123
+ ```
124
+
108
125
## Development
109
126
110
127
``` bash
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ generator client {
11
11
}
12
12
13
13
generator dbml {
14
- provider = " node ./dist/generator.js "
14
+ provider = " node ./dist/generator.js "
15
+ output = " ../dbml "
16
+ outputName = " awesome.dbml "
15
17
}
16
18
17
19
model User {
Original file line number Diff line number Diff line change @@ -5,24 +5,23 @@ import { join } from 'path';
5
5
6
6
const { mkdir, writeFile } = promises ;
7
7
8
+ export const defaultDBMLFileName = 'schema.dbml' ;
9
+
8
10
export async function generate ( options : GeneratorOptions ) {
9
- if ( options . generator . output ) {
10
- try {
11
- await mkdir ( options . generator . output , { recursive : true } ) ;
11
+ const outputDir = options . generator . output ! ;
12
+ const dbmlFileName =
13
+ options . generator . config . outputName || defaultDBMLFileName ;
14
+
15
+ try {
16
+ await mkdir ( outputDir , { recursive : true } ) ;
12
17
13
- // await writeFile('./test.json', JSON.stringify(options.dmmf.datamodel));
18
+ // await writeFile('./test.json', JSON.stringify(options.dmmf.datamodel));
14
19
15
- const dbmlSchema = generateDBMLSchema ( options . dmmf ) ;
20
+ const dbmlSchema = generateDBMLSchema ( options . dmmf ) ;
16
21
17
- await writeFile (
18
- join ( options . generator . output , 'schema.dbml' ) ,
19
- dbmlSchema
20
- ) ;
21
- } catch ( e ) {
22
- console . error ( 'Error: unable to write files for Prisma DBML Generator' ) ;
23
- throw e ;
24
- }
25
- } else {
26
- throw new Error ( 'No output was specified for Prisma DBML Generator' ) ;
22
+ await writeFile ( join ( outputDir , dbmlFileName ) , dbmlSchema ) ;
23
+ } catch ( e ) {
24
+ console . error ( 'Error: unable to write files for Prisma DBML Generator' ) ;
25
+ throw e ;
27
26
}
28
27
}
You can’t perform that action at this time.
0 commit comments