Hi there, when I generate my prisma client, it doe...
# prisma-client
r
Hi there, when I generate my prisma client, it doesn't seem to add the relation models. For example:
Copy code
export type LessonsCompleted = {
  id: number
  watchedVideo: boolean
  readText: boolean
  completionDate: Date | null
  userId: string
  lessonId: number
}
has a relation to
Lesson
, however the generate command doesn't add that to the client. I can manually add
lesson: Lesson
to my
LessonsCompleted
model and I'm able to select the lesson as needed, however when I regenerate my client, that is undone and the field is no longer on the model. Is there anyway to get around this? Am I misunderstanding something?
โœ… 1
n
Hey Robert ๐Ÿ‘‹ Relation fields are not included by default in Prisma Client queries. Here your model LessonsCompleted only contains the scalar fields. To include the relation fields you would need to use
LessonsCompletedGetPayload
type that is generated and exposed by Prisma Client under the
Prisma
namespace in combination with the
validator
. Hereโ€™s a guide on how exactly you can achieve it: Using Variations of Generated model type
๐Ÿ‘ 1
r
Amazing, much appreciated @Nurul
๐Ÿ™Œ 1