-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
99 lines (90 loc) · 2.63 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())
anonname String @unique
password String
isAdmin Boolean @default(false)
email String @unique
photo String?
location String @default("")
posts Post[]
comments Comments[]
postlikes PostLike[]
commentlikes CommentLike[]
bookmarks Bookmarks[]
// category Category[]
}
model Post {
id String @id @default(uuid())
intId Int @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
published Boolean @default(false)
title String @db.VarChar(165)
content String
author User @relation(fields: [authorId], references: [id])
deleted Boolean @default(false)
postimage String?
authorId String
comments Comments[]
category Category? @relation(fields: [categoryId], references: [id])
categoryId String?
likes PostLike[]
trending Trending?
bookmarks Bookmarks[]
likesCount Int?
//@@index([authorId,id])
}
model Comments {
id String @id @default(uuid())
text String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
post Post @relation(fields: [postId], references: [id])
commenter User @relation(fields: [commenterId], references: [id])
commenterId String
postId String
likes CommentLike[]
}
//consider making the title field below unique
model Category {
id String @id @default(uuid())
title String
posts Post[]
// author User? @relation(fields: [authorId], references: [id])
// authorId String
}
model PostLike {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId String
post Post? @relation(fields: [postId], references: [id])
postId String
}
model CommentLike {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId String
comment Comments? @relation(fields: [commentId], references: [id])
commentId String
}
model Trending {
id String @id @default(uuid())
post Post @relation(fields: [postId], references: [id])
postId String @unique
createdAt DateTime @default(now())
}
model Bookmarks {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId String
post Post @relation(fields: [postId], references: [id])
postId String
}