hi, anyone knows how to do conditional search cond...
# orm-help
t
hi, anyone knows how to do conditional search condition? I.e if I only want to search for not null name if my variable is true
Copy code
prisma.people.findMany({ where: { what here? }})
1
h
Hey Tri 👋 I think the easiest way to go about doing that is by adding another variable up top, and adding that onto your Prisma schema for where. If I understood your question wrong, my apologies. I wasn't able to quite grasp what you were saying or having trouble with 😅
n
Hey👋, You would need to create a where clause before passing it in query. Something like this:
Copy code
if (your_variable) {
    where = {
      name: { not: null },
    };
  } else {
    where = {};
  }

  await prisma.people.findMany(where);