M1_ProjetWeb/prisma/schema.prisma

49 lines
1.4 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"
binaryTargets = ["debian-openssl-1.1.x", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"]
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
username String @unique
profilePicture String @default("default.png")
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
}