t4ut4ut4u
t4ut4ut4u
PPrisma
Created by t4ut4ut4u on 8/24/2024 in #help-and-questions
Ordering by a nullable relation
Hello everyone, so I have the following schema:
model UserPrisma {
id String @id @default(uuid())
createdAt DateTime @default(now())
email String @unique
name String
surname String

reservations ReservationPrisma[] @relation("reservation")
}

model ReservationPrisma {
id String @id @default(uuid())
createdAt DateTime @default(now())
date DateTime

userId String?
user UserPrisma? @relation("reservation", fields: [userId], references: [id], onDelete: Cascade)
}
model UserPrisma {
id String @id @default(uuid())
createdAt DateTime @default(now())
email String @unique
name String
surname String

reservations ReservationPrisma[] @relation("reservation")
}

model ReservationPrisma {
id String @id @default(uuid())
createdAt DateTime @default(now())
date DateTime

userId String?
user UserPrisma? @relation("reservation", fields: [userId], references: [id], onDelete: Cascade)
}
how to query ReservationPrisma ordering by user.surname? Thank you.
2 replies