Files
spsays-training/prisma/schema.prisma
T
2026-05-04 00:30:13 +05:30

290 lines
9.6 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
// ---------------------------------------------------------------------------
// Synonym — embedded document inside Verse
// ---------------------------------------------------------------------------
type Synonym {
word String
meanings String[]
}
// ---------------------------------------------------------------------------
// Verse — unified model for BG, SB, and CC verses
//
// book: "bg" | "sb" | "cc"
// division: null for BG, canto number string for SB ("1"-"10"),
// līlā key for CC ("adi", "madhya", "antya")
// chapter: chapter number
// verse: verse number (first verse number for multi-verse entries)
// verseEnd: last verse number for multi-verse entries (e.g. 18 for "16-18")
// reference: display reference string (e.g. "Bg 1.1", "SB 1.1.1", "Cc Ādi 1.1")
// ---------------------------------------------------------------------------
model Verse {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String // "bg" | "sb" | "cc"
division String? // null for BG; canto for SB; lila for CC
chapter Int
verse Int
verseEnd Int?
reference String
bookTitle String
devanagari String
bengali String? // only CC has Bengali
transliteration String
synonyms Synonym[]
translation String
purport String[]
@@unique([book, division, chapter, verse])
@@index([book])
@@index([book, division])
@@index([book, division, chapter])
@@map("verses")
}
// ---------------------------------------------------------------------------
// BookMeta — stores the intro.json data for each book
//
// The `data` field stores the entire intro JSON as a flexible JSON blob,
// since BG/SB/CC each have different structures (chapters vs cantos vs lilas).
// ---------------------------------------------------------------------------
model BookMeta {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String @unique // "bg" | "sb" | "cc"
data Json
@@map("book_meta")
}
// ---------------------------------------------------------------------------
// ProseChapter — for prose books like Kṛṣṇa Book (no verse structure)
//
// book: "kb"
// volume: volume number (1 or 2 for KB)
// chapter: chapter number within the volume
// title: chapter title
// type: "chapter" | "intro-segment"
// slug: URL-friendly identifier (e.g. "01", "preface", "words-from-apple")
// order: sort order (chapter number for chapters, custom for intro segments)
// paragraphs: array of HTML paragraph strings
// ---------------------------------------------------------------------------
model ProseChapter {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String // "kb"
volume Int
chapter Int? // null for intro segments
title String
type String // "chapter" | "intro-segment"
slug String
order Int
paragraphs String[]
@@unique([book, volume, slug])
@@index([book])
@@index([book, volume])
@@index([book, volume, type])
@@map("prose_chapters")
}
// ---------------------------------------------------------------------------
// Essay — standalone essays (not part of any book's chapter structure)
//
// slug: URL-friendly identifier (e.g. "krishna-reservoir-of-pleasure")
// title: essay title
// author: author name
// year: publication year
// group: optional grouping key (e.g. "two-essays" for essays published together)
// order: sort order within a group
// paragraphs: array of HTML paragraph strings
// ---------------------------------------------------------------------------
model Essay {
id String @id @default(auto()) @map("_id") @db.ObjectId
slug String @unique
title String
author String
year Int?
group String?
order Int
paragraphs String[]
@@index([group])
@@map("essays")
}
// ---------------------------------------------------------------------------
// OtherDocumentMeta — metadata for miscellaneous documents
//
// book: slug identifier (e.g. "analysis-bg", "real-peace-formula")
// data: JSON blob containing title, author, year, description, chapters list
// ---------------------------------------------------------------------------
model OtherDocumentMeta {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String @unique
data Json
@@map("other_document_meta")
}
// ---------------------------------------------------------------------------
// OtherDocumentChapter — chapters within other documents
//
// book: slug identifier matching OtherDocumentMeta.book
// chapter: chapter number
// title: chapter title
// type: "chapter"
// slug: URL-friendly identifier (chapter number as string)
// order: sort order
// paragraphs: array of HTML paragraph strings
// ---------------------------------------------------------------------------
model OtherDocumentChapter {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String
chapter Int
title String
type String
slug String
order Int
paragraphs String[]
@@unique([book, slug])
@@index([book])
@@map("other_document_chapters")
}
// ---------------------------------------------------------------------------
// JournalMeta — metadata for journals (Jaladuta Diary, The Beginning, etc.)
//
// book: slug identifier (e.g. "jaladuta-diary", "the-beginning")
// data: JSON blob containing title, author, year, description, chapters list
// ---------------------------------------------------------------------------
model JournalMeta {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String @unique
data Json
@@map("journal_meta")
}
// ---------------------------------------------------------------------------
// JournalChapter — chapters within journals
//
// book: slug identifier matching JournalMeta.book
// chapter: chapter number
// title: chapter title
// type: "chapter" | "preface" | "introduction"
// slug: URL-friendly identifier (chapter number as string)
// order: sort order
// paragraphs: array of HTML paragraph strings
// ---------------------------------------------------------------------------
model JournalChapter {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String
chapter Int
title String
type String
slug String
order Int
paragraphs String[]
@@unique([book, slug])
@@index([book])
@@map("journal_chapters")
}
// ---------------------------------------------------------------------------
// MagazineMeta — metadata for magazines (Back to Godhead, etc.)
//
// book: slug identifier (e.g. "btg")
// data: JSON blob containing title, author, description, volumes/issues list
// ---------------------------------------------------------------------------
model MagazineMeta {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String @unique
data Json
@@map("magazine_meta")
}
// ---------------------------------------------------------------------------
// MagazineIssue — individual issues within a magazine
//
// book: slug identifier matching MagazineMeta.book
// volume: volume number
// part: part/issue number within the volume
// title: display title (e.g. "Volume 3, Part 5, May 5, 1956")
// slug: URL-friendly identifier (e.g. "v3-p5")
// order: sort order
// paragraphs: array of HTML paragraph strings (all articles concatenated)
// ---------------------------------------------------------------------------
model MagazineIssue {
id String @id @default(auto()) @map("_id") @db.ObjectId
book String
volume Int
part Int
title String
slug String
order Int
paragraphs String[]
@@unique([book, slug])
@@index([book])
@@index([book, volume])
@@map("magazine_issues")
}
// ---------------------------------------------------------------------------
// GlossaryEntry — individual glossary term + definition
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Letter — individual letters written by Śrīla Prabhupāda
//
// slug: unique identifier (e.g. "47-07-12-mahatma-gandhi", "68-01-15-hayagriva")
// recipients: array of individual recipient names (split from comma-separated)
// recipientDisplay: original recipient string for display (e.g. "Mukunda, Janaki")
// date: date string as written (e.g. "12 July, 1947")
// dateRef: reference code (e.g. "47-07-12")
// year: extracted year number for filtering/grouping
// month: extracted month number (1-12) for filtering
// day: extracted day number for filtering
// location: city/place where the letter was written
// salutation: the "Dear..." line
// paragraphs: array of HTML paragraph strings (letter body)
// ---------------------------------------------------------------------------
model Letter {
id String @id @default(auto()) @map("_id") @db.ObjectId
slug String @unique
recipients String[]
recipientDisplay String
date String?
dateRef String?
year Int?
month Int?
day Int?
location String?
salutation String?
paragraphs String[]
@@index([year])
@@index([recipients])
@@index([location])
@@index([year, month])
@@map("letters")
}
model GlossaryEntry {
id String @id @default(auto()) @map("_id") @db.ObjectId
term String
definition String
definitionHtml String
@@unique([term])
@@map("glossary")
}