47 lines
1.2 KiB
Text
47 lines
1.2 KiB
Text
// 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(auto()) @map("_id") @db.ObjectId
|
|
username String @unique
|
|
surname String
|
|
name String
|
|
email String @unique
|
|
password String
|
|
messages Message[]
|
|
|
|
@@map("users") // Table name in DB
|
|
}
|
|
|
|
model Channel {
|
|
id String @id @default(auto()) @map("_id") @db.ObjectId
|
|
name String @unique
|
|
messages Message[]
|
|
createdAt DateTime @default(now())
|
|
|
|
@@map("channels") // Table name in DB
|
|
}
|
|
|
|
model Message {
|
|
id String @id @default(auto()) @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
|
|
}
|