Dennis
06/25/2021, 7:28 PMDennis
06/25/2021, 7:29 PM// This is your Prisma schema file,
// learn more about it in the docs: <https://pris.ly/d/prisma-schema>
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Department {
id Int @default(autoincrement()) @id
name String @unique
description String?
studyCourses StudyCourse[]
lecturers Lecturer[]
}
model StudyCourse {
id Int @default(autoincrement()) @id
name String @unique
degree String
department Department @relation(fields: [departmentId],references: [id])
departmentId Int @unique
students Student[]
}
model Student {
id String @id
title String @default("")
firstname String
lastname String
gender Gender
birthdate DateTime
mail String
phone String?
active Boolean
course StudyCourse? @relation(fields: [courseId],references: [id])
courseId Int?
semester Int
matriculationsNumber String
}
model Lecturer {
id String @id
title String @default("")
firstname String
lastname String
gender Gender
birthdate DateTime
mail String
phone String?
active Boolean
department Department @relation(fields: [departmentId],references: [id])
departmentId Int
}
model Administrative {
id String @id
title String @default("")
firstname String
lastname String
gender Gender
birthdate DateTime
mail String
phone String
active Boolean
}
enum Gender {
MALE
FEMALE
DIVERSE
}
Dennis
06/25/2021, 9:13 PMDennis
06/25/2021, 9:19 PMFilippo Sarzana
06/25/2021, 10:32 PMcourse StudyCourse @relation(fields: [courseId],references: [id])
Without the ?
on Student
model should solve the problemDennis
06/26/2021, 8:41 AMexport type Student = {
id: string
title: string
firstname: string
lastname: string
gender: Gender
birthdate: Date
mail: string
phone: string | null
active: boolean
courseId: number
semester: number
matriculationsNumber: string
test: number
}
with ?
export type Student = {
id: string
title: string
firstname: string
lastname: string
gender: Gender
birthdate: Date
mail: string
phone: string | null
active: boolean
courseId: number | null
semester: number
matriculationsNumber: string
test: number
}
Filippo Sarzana
06/26/2021, 6:03 PMcourse StudyCourse
courseId Int
Both these should be without ?
But I think that - since we are speaking of a relation that might be null
the ?
should be kept and you should recreate a type
type StudentWithRequiredCourse = Student && Required<Pick<Student, 'course'>>
This should somehow work for youBenjamin Kroeger
06/26/2021, 6:51 PMDennis
06/27/2021, 12:18 PMDennis
06/27/2021, 12:19 PM