File tree 3 files changed +28
-9
lines changed
3 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,18 @@ Table Post {
29
29
published Boolean [not null, default: false]
30
30
author User
31
31
authorId Int
32
+ categories Category
33
+ }
34
+
35
+ Table Category {
36
+ id Int [pk, increment]
37
+ name String [not null]
38
+ posts Post
39
+ }
40
+
41
+ Table CategoryToPost {
42
+ categoryId Int [ref: > Category.id]
43
+ postId Int [ref: > Post.id]
32
44
}
33
45
34
46
Enum Role {
Original file line number Diff line number Diff line change @@ -35,12 +35,19 @@ model Profile {
35
35
}
36
36
37
37
model Post {
38
- id Int @id @default (autoincrement () )
39
- title String @default (" " )
40
- content String ?
41
- published Boolean @default (false )
42
- author User ? @relation (fields : [authorId ] , references : [id ] )
43
- authorId Int ?
38
+ id Int @id @default (autoincrement () )
39
+ title String @default (" " )
40
+ content String ?
41
+ published Boolean @default (false )
42
+ author User ? @relation (fields : [authorId ] , references : [id ] )
43
+ authorId Int ?
44
+ categories Category []
45
+ }
46
+
47
+ model Category {
48
+ id Int @id @default (autoincrement () )
49
+ name String
50
+ posts Post []
44
51
}
45
52
46
53
/// user role
Original file line number Diff line number Diff line change @@ -11,15 +11,15 @@ export async function generate(options: GeneratorOptions) {
11
11
const outputDir = options . generator . output ! ;
12
12
const dbmlFileName =
13
13
options . generator . config . outputName || defaultDBMLFileName ;
14
-
15
- const allowManyToMany = options . generator . config . manyToMany || true ;
14
+ const allowManyToMany =
15
+ options . generator . config . manyToMany === 'false' ? false : true ;
16
16
17
17
try {
18
18
await mkdir ( outputDir , { recursive : true } ) ;
19
19
20
20
// await writeFile('./test.json', JSON.stringify(options.dmmf.datamodel));
21
21
22
- const dbmlSchema = generateDBMLSchema ( options . dmmf , manyToMany ) ;
22
+ const dbmlSchema = generateDBMLSchema ( options . dmmf , allowManyToMany ) ;
23
23
24
24
await writeFile ( join ( outputDir , dbmlFileName ) , dbmlSchema ) ;
25
25
} catch ( e ) {
You can’t perform that action at this time.
0 commit comments