// 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") } model User { id String @id @default(cuid()) @map("_id") @db.ObjectId username String @unique surname String name String email String @unique password String channels Channel[] @relation(fields: [channelIDs], references: [id]) channelIDs String[] @db.ObjectId messages Message[] @@map("users") // Table name in DB } model Channel { id String @id @default(cuid()) @map("_id") @db.ObjectId name String topic String users User[] @relation(fields: [userIDs], references: [id]) userIDs String[] @db.ObjectId messages Message[] @@map("channels") // Table name in DB } model Message { id String @id @default(cuid()) @map("_id") @db.ObjectId user User @relation(fields: [userId], references: [id]) userId String @db.ObjectId channel Channel @relation(fields: [channelId], references: [id]) channelId String @db.ObjectId text String createdAt DateTime @default(now()) @@map("messages") // Table name in DB }