how can I get a record from the db by providing an...
# orm-help
e
how can I get a record from the db by providing an enum argument instead of id? It is the id that I want to figure out and I want the client to provide an enum instead. Im thinking something like this:
Copy code
const device = await prisma.device.findUnique({
      where: {
        deviceType: {
          contains: args.data.deviceType
        }
      },
      connect: {
        user: {
          id: userId
        }
      }
    });
This obviously doesnt work but hopefully you would get the idea.
r
@Edmir Suljic 👋 You can use
findFirst
.
e
👋 Hmm.. I have a hard time wrapping my head around the arguments you can use... I feel like I'm using the where and include arguments correctly but well obviously not
r
ctrl + space
is your friend. You can easily find all arguments and methods that need to be passed.
e
good point. I'll have to get used to that
figured it out btw. What worked was:
Copy code
onst device = await prisma.device.findFirst({
      where: {
        deviceType: args.data.deviceType
      },
      include: {
        user: true
      }
    });
💯 1