157 lines
4.3 KiB
Plaintext
157 lines
4.3 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mongodb"
|
|
url = env("MONGODB_URI")
|
|
}
|
|
|
|
// datasource db {
|
|
// provider = "mongodb"
|
|
// url = env("DATABASE_URL")
|
|
// }
|
|
|
|
model Account {
|
|
id String @id @default(cuid()) @map("_id")
|
|
userId String
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String?
|
|
access_token String?
|
|
expires_at Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String?
|
|
session_state String?
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([provider, providerAccountId])
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid()) @map("_id")
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid()) @map("_id")
|
|
name String?
|
|
email String @unique
|
|
emailVerified DateTime?
|
|
image String?
|
|
isAdmin Boolean @unique @default(false)
|
|
accounts Account[]
|
|
sessions Session[]
|
|
Post Post[]
|
|
Like Like[]
|
|
Comment Comment[]
|
|
Favorite Favorite[]
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String @id @map("_id")
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|
|
|
|
model Category {
|
|
id String @id @default(cuid()) @map("_id")
|
|
slug String @unique
|
|
title String
|
|
img String?
|
|
color String?
|
|
Posts Post[]
|
|
Comment Comment[]
|
|
}
|
|
|
|
// model Tag {
|
|
// id String @id @default(cuid()) @map("_id")
|
|
// name String @unique
|
|
// slug String @unique
|
|
// color String?
|
|
// // Posts PostTag[]
|
|
// Post Post? @relation(fields: [postId], references: [id])
|
|
// postId String?
|
|
// }
|
|
|
|
// model PostTag {
|
|
// id String @id @default(cuid()) @map("_id")
|
|
// postId String
|
|
// tagId String
|
|
// post Post @relation(fields: [postId], references: [id])
|
|
// tag Tag @relation(fields: [tagId], references: [id])
|
|
|
|
// @@unique([postId, tagId])
|
|
// }
|
|
|
|
model Post {
|
|
id String @id @default(cuid()) @map("_id")
|
|
slug String @unique
|
|
title String
|
|
description String
|
|
img String?
|
|
views Int @default(0)
|
|
catSlug String?
|
|
Category Category? @relation(fields: [catSlug], references: [slug])
|
|
userEmail String
|
|
user User @relation(fields: [userEmail], references: [email], onDelete: Cascade)
|
|
Like Like[]
|
|
comments Comment[]
|
|
url String?
|
|
twitterShareCount Int @default(0)
|
|
whatsappShareCount Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
Favorite Favorite[]
|
|
// PostTag PostTag[]
|
|
// Tags Tag[]
|
|
}
|
|
|
|
model Like {
|
|
id String @id @default(cuid()) @map("_id")
|
|
postId String
|
|
post Post @relation(fields: [postId], references: [id])
|
|
userEmail String
|
|
user User @relation(fields: [userEmail], references: [email], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([postId, userEmail])
|
|
}
|
|
|
|
model Favorite {
|
|
id String @id @default(cuid()) @map("_id")
|
|
postId String
|
|
post Post @relation(fields: [postId], references: [id])
|
|
userEmail String
|
|
user User @relation(fields: [userEmail], references: [email], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([postId, userEmail])
|
|
}
|
|
|
|
model Comment {
|
|
id String @id @default(cuid()) @map("_id")
|
|
createdAt DateTime @default(now())
|
|
description String
|
|
userEmail String
|
|
user User @relation(fields: [userEmail], references: [email], onDelete: Cascade)
|
|
postSlug String
|
|
post Post @relation(fields: [postSlug], references: [slug])
|
|
|
|
Category Category? @relation(fields: [categoryId], references: [id])
|
|
categoryId String?
|
|
}
|