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.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server