Fernando
08/08/2022, 3:51 PMwhere
OR
condition but I get nothing back, this is what it looks like:
await prisma.transaction.findMany({
where: {
OR: [
{
description: {
contains: paramKeyword ? paramKeyword : undefined
},
value: {
equals:
paramKeyword && !isNaN(parseInt(paramKeyword)) ? parseInt(paramKeyword) : undefined
}
}
]
}
});
Basically I'm trying to implement a really basic search from url params.
The column types are description: string
and value: number
.
If I comment description
or value
and change nothing else I do get results, but when both conditions are present I get an empty array.
Not sure if it matters, but this is on a SQLite db.
What am I missing?
Thanks!Michael Jay
08/09/2022, 12:29 AMOR: [
{description: {...}},
{value: {...}}
]
Michael Jay
08/09/2022, 12:35 AMOR: [{query obj 1}, {query obj 2}, ...]
You've got:
OR: [{{query obj 1}, {query obj 2}}]
, where since your two query statements are in one object, it's an implicit AND.Fernando
08/09/2022, 2:29 PMMichael Jay
08/09/2022, 3:02 PM