help with prisma schema (coming from sql)

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
email String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
+ Slot Slot? @relation(fields: [slotId], references: [id])
+ slotId String? @db.ObjectId
}

model Slot {
id String @id @default(auto()) @map("_id") @db.ObjectId
timestamp DateTime @unique
+ users User[]
}
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
email String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
+ Slot Slot? @relation(fields: [slotId], references: [id])
+ slotId String? @db.ObjectId
}

model Slot {
id String @id @default(auto()) @map("_id") @db.ObjectId
timestamp DateTime @unique
+ users User[]
}
1 Reply
harshcut
harshcutOP2y ago
I want to create a collections named Slot with id, timestamp, and an array of objects which are from User collection. How do I do it? User[] seems like a good place to start, and Slot and slotId are added by prisma extension.
Want results from more Discord servers?
Add your server