Hey guys, how's it going? I'd like some help from ...
# orm-help
f
Hey guys, how's it going? I'd like some help from you. I have this type
Copy code
type UserIntensitySetting {
  id: UUID! @id
  category: WorkoutCategory!
  historicalIntensitySettings: [HistoricalIntensitySetting!]! @relation(onDelete: CASCADE)
  user: User!
  createdAt: DateTime! @createdAt
}
So, I can do this
Copy code
... await context.prisma.userIntensitySetting({ id: 'asdf-basdf-waaa-234' });
The problem is I'd like to do this query
Copy code
... await context.prisma.userIntensitySetting({ category: 'strength' });
But I got an error saying this field is not in the schema. My question is: how could I do this query and use other fields beside the id field?
👀 1
a
The where inside that query refers only to unique fields
category is not unique and you can't use prisma that way
I'm not sure about Prisma 1, I use prisma 2, but in 2, instead of using
findUnique
you'd use
findFirst
So in Prisma 1, I guss you'll have to fetch it as a list when filtering by category
n
Hey Felipe 👋 What Aladin mentioned is correct, for the
findUnique
query you can only refer to fields which has
@unique
attribute. Are you using Prisma1?
a
Yeah, check his schema, it's Prisma 1