/
MariaTsys
/
courseworkPP
Обзор
Документация
Войти
/
MariaTsys
/
courseworkPP
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
prisma/schema.prisma
116 строк
4 KB
Maria
first_commit
09 май 2025, 12:17
09 май 2025, 12:17
af55308
Код
Авторство
О чём код?
// 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 = "postgresql" // NOTE: When using mysql or sqlserver, uncomment the @db.Text annotations in model Account below // Further reading: // https://next-auth.js.org/adapters/prisma#create-the-prisma-schema // https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string url = env("DATABASE_URL") } // Necessary for Next auth model Account { id String @id @default(cuid()) userId String type String provider String providerAccountId String refresh_token String? // @db.Text access_token String? // @db.Text expires_at Int? token_type String? scope String? id_token String? // @db.Text session_state String? user User @relation(fields: [userId], references: [id], onDelete: Cascade) refresh_token_expires_in Int? @@unique([provider, providerAccountId]) } model Session { id String @id @default(cuid()) sessionToken String @unique userId String expires DateTime user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model User { id String @id @default(cuid()) name String? email String? @unique emailVerified DateTime? image String? accounts Account[] sessions Session[] ratings Rating[] // Рейтинги книг bookStatuses BookStatus[] role Role @default(USER) } enum Role { USER ADMIN } model VerificationToken { identifier String token String @unique expires DateTime @@unique([identifier, token]) } // Модель книги model Book { id String @id @default(cuid()) title String? author String? genre String? coverUrl String? // Обложка книги content String? // Содержание книги rating Float? // Средний рейтинг createdAt DateTime @default(now()) // Дата создания книги ratings Rating[] statuses BookStatus[] } // Модель для хранения рейтингов книг model Rating { id String @id @default(cuid()) value Float? // Рейтинг книги bookId String userId String book Book @relation(fields: [bookId], references: [id], onDelete: Cascade) user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([userId, bookId]) } // Подборки книг enum ReadStatus { WANT_TO_READ // Хочу прочитать READING // Читаю READ // Прочитал } model BookStatus { id String @id @default(cuid()) userId String bookId String status ReadStatus // Статус прочтения liked Boolean? @default(false) user User @relation(fields: [userId], references: [id], onDelete: Cascade) book Book @relation(fields: [bookId], references: [id], onDelete: Cascade) @@unique([userId, bookId]) // Каждая книга у пользователя может иметь только один статус }