Assignment8/prisma/schema.prisma

46 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2025-01-24 04:57:47 +00:00
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL") //In the env file
}
model Blog {
id Int @id @default(autoincrement())
slug String
title String
body String
coverImage String?
categoryIDs String // or Int[] depending on your use case
tagIDs String // or Int[] depending on your use case
createdAt DateTime @default(now())
}
model Category {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
blogIDs String[] @db.ObjectId
blogs Blog[] @relation("BlogCategories", fields: [blogIDs], references: [id])
}
model Tag {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
blogIDs String[] @db.ObjectId
blogs Blog[] @relation("BlogTags", fields: [blogIDs], references: [id])
}
model Comment {
id String @id @default(auto()) @map("_id") @db.ObjectId
comment String
blogId String @db.ObjectId
blog Blog @relation(fields: [blogId], references: [id])
}