<@UCZMXEP3J> When making queries such as `context....
# orm-help
c
@Harshit When making queries such as
context.prisma.user({ id: args.user.id })
It appears that I can only do searches on certain fields, maybe ones marked as unique? Or maybe just IDs? If I try to run
context.prisma.user({ email: '<mailto:corey@test.com|corey@test.com>' })
prisma throws errors that email isn’t on the list of properties which can be searched. This requires me to instead use
context.prisma.users({ where: {email: '<mailto:corey@test.com|corey@test.com>' }})
which returns an array of items which I immediately have to get at the first item in the array like:
Copy code
let user = (await context.prisma.users({
        where: {
          email: args.email.toLowerCase(),
        }
      }))[0] <<-- this part kinda sucks..
Am I doing this wrong? Is there a better way to go about it?
h
This is expected. If something is not unique, it will return a list of items because more than one of them can satisfy the condition.
c
Ahh ok. So if I have email marked as unique, can it be searched with
user()
Copy code
type User {
    id: ID! @id
    name: String!
    email: String! @unique
h
yes
c
Great, thanks! I sincerely appreciate your replies.