My question is as simple as that : I have a query and I am looking for a match on a string such as :
const test_name = 'ExAmPlE'
const database_resources = await prisma.market.findMany({
where: {
name: test_name
}
})
I can use string.toLowerCase() but only on specific use cases
How can I get all of the rows where name can be anything such as Example, ExAMple or example but not any other key such as Exàmplé ?
CodePudding user response:
You can try out the following:
prisma.market.findMany({
where: {
name: {
contains: filter
}
}
})
And if you want to filter using more than one property, you can try out the following
prisma.market.findMany({
where: {
OR: [
{
name: {
contains: filter
}
},
{
description: {
contains: filter
}
}
]
}
})
CodePudding user response:
Just use mode: 'insensitive':
const test_name = 'ExAmPlE'
const database_resources = await prisma.market.findMany({
where: {
name: {
equals: test_name,
mode: 'insensitive'
}
}
})
