-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathschema.prisma
51 lines (43 loc) · 1.12 KB
/
schema.prisma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
output = "./node_modules/.prisma/client"
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String?
email String @unique
password String
role UserRole
articles Article[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("users")
}
enum UserRole {
admin
writer
}
model Article {
id String @id @default(auto()) @map("_id") @db.ObjectId
createdBy User @relation(fields: [author], references: [id])
author String @db.ObjectId
title String
body String
published Boolean @default(false)
comments Comment[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("articles")
}
model Comment {
id String @id @default(auto()) @map("_id") @db.ObjectId
articleId String @db.ObjectId
article Article @relation(fields: [articleId], references: [id])
author String
text String
@@map("comments")
}