blog-app/server/prisma/schema.prisma

44 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2025-01-22 12:51:52 +00:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
model Blog {
id String @id @default(auto()) @map("_id") @db.ObjectId
slug String @unique
title String
body String
comments Comment[]
categoryIDs String[] @db.ObjectId
categories Category[] @relation(fields: [categoryIDs], references: [id])
tagIDs String[] @db.ObjectId
tags Tag[] @relation(fields: [categoryIDs], references: [id])
}
model Comment {
id String @id @default(auto()) @map("_id") @db.ObjectId
comment String
blog Blog @relation(fields: [blogId], references: [id])
blogId String @db.ObjectId
}
model Category {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
blogIDs String[] @db.ObjectId
blogs Blog[] @relation(fields: [blogIDs], references: [id])
}
model Tag {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
blogIDs String[] @db.ObjectId
blogs Blog[] @relation(fields: [blogIDs], references: [id])
}