Mathie
05/05/2022, 4:39 PMmodel Response {
id Int @id @default(autoincrement())
survey Survey @relation(fields: [surveyId], references: [id])
surveyId Int
user User @relation(fields: [userId], references: [id])
userId Int
sendAt DateTime @default(now())
json Json
}
How to use findUnique on the field user ?
I want to get the user with the ID 1Ruben Amendoeira
05/05/2022, 4:41 PMMathie
05/05/2022, 4:44 PM_const_ survey = _this_.responseService.response({
where: {
user: req.user.id
},
});
I get the error:
Type '{ user: any; }' is not assignable to type 'ResponseWhereUniqueInput'.
nestjs_1 | A literal object can specify only known properties, and 'user' does not exist in the type 'ResponseWhereUniqueInput'.Ruben Amendoeira
05/05/2022, 5:08 PMwhere: { user: ... } and you cannot query by "user" object, you can however query by the user id, like so:
where: { userId: req.user.id }Yuval Datner
05/05/2022, 11:31 PM@unique, that is