As a newcomer to Prisma, I am facing an issue while trying to update a field based on a foreign key. The error message I receive is:
Type '{ authorId: number; }' is not assignable to type 'PatientWhereUniqueInput'.
Here is my schema for reference:
id Int @id @default(autoincrement())
name String?
password String
email String @unique
patient Patient[]
}
model Patient {
id Int @id @default(autoincrement())
firstName String
lastName String
email String @unique
password String
contact String
address String
dob String
image String?
author User @relation(fields: [authorId], references: [id])
authorId Int
specialAttention Boolean @default(false)
}
In order to update the patient data, I am utilizing the following method, with userId representing the currently logged in user's Id retrieved from the middleware:
const updatedPatient = await prisma.patient.update({
where: {
authorId: userId,
},
data: body,
});
return updatedPatient;
};