Prisma Docs not working as instructed for insensitive case search. 9am and my brain hurts.
I am using the input of a URL to then query my database, so for example
Discord
. This works correctly, however it doesn't work for lower case, such as discord
.
Looking at the Prisma docs (https://www.prisma.io/docs/concepts/components/prisma-client/case-sensitivity) it instructs me to to use mode: 'insensitive',
. This does not work and the TypeScript error is as follows when placing the code under has: input,
I believe this is telling me because I don't have a mode
in the database, it can't be used. Which makes sense? But then what is the correct way to filter case insensitive?10 Replies
instead of
has
try contains
https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#contains
the mode you're concerned about is this
https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#modeactually, not sure what default of mode is (not using prisma rn)
I'm using Postgres, so by default it's case sensitive hence the issue.
Same error using
contains
. I am the noob here so I am sure its something obvious I am not considering but got no idea..
Is this just a TypeScript issue thing? Where it thinks there will be an error but Prisma handles it correctly?
has
does auto complete in vscode, contains
and mode
do not, so version? I got no ideaoh so the query goes through properly?
also, i think there should be an await?
and if it's a typing issue maybe doing a typescript server reset is necessary
cmd + shift + p
-> Restart TS server
Tried that, tried reboot and all
Will add the await!
So, I tried it on a different query, it works fine!
It seems because I store the data in an array, I'll have to lookup how to do it with those
If its a string, these all work, if its an array, I guess not?
oh serverTypes is an array?
and yeah, what we've been talking about was how to query a string
this part of the docs should help out @Debaucus
https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-scalar-lists-arrays
Prisma
Working with scalar lists/arrays (Concepts)
How to read, write, and filter by scalar lists / arrays.
your original
has
was really close looks likeNot seeing something that would cover case sensitivity 😦
Even chatgpt keeps spitting out
use raw
which 1 is bad and 2 doesn't work a raw isn't an accepted value here either!