Hello ! My model : `model Response {` `id ...
# orm-help
m
Hello ! My model :
model 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 1
m
No, I can't do it on a relationship. For the code:
_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'.
r
you're doing
where: { user: ... }
and you cannot query by "user" object, you can however query by the user id, like so:
Copy code
where: { userId: req.user.id }
y
only if userId is
@unique
, that is