Hi guys, Has a solution already been made for case...
# orm-help
v
Hi guys, Has a solution already been made for case insensitive findMany querying? For example, here I would like to search in the title field, but contains is case sensitive. I am looking for an option in the API, or something like "containsInsensitive:searchString"
Copy code
return ctx.prisma.post.findMany({
      where: {
        OR: [
          {
            title: {
              contains: searchString,
            },
          },
          {
            content: {
              contains: searchString,
            },
          },
        ],
      },
    })
👍 1
r
👍 2
j
this was also a problem in prisma 1. but now at least we have accese to raw sql. so... `searchString = `%${searchString}%`` `const posts = await prisma.raw`SELECT * FROM Post WHERE LOWER(title) LIKE ${search} OR title LOWER(content) ${search};`;`
v
Thanks for you answer @Joshua Waurich , it helped me a lot! Just a little addition to your solution: I had to wrap the
${search}
variable with quotation marks (
'${search}'
) to make it work.
👍 1
j
I also hit this exact problem earlier today
c