P
Prisma•4mo ago
thejacer87

check for multiple conditions on the same field

i think there is a simple solution that i am over looking but i am building this query:
where: {
AND: [
{ key_id: { in: branchKeyIds } },
{ key_id: { notIn: machineSpecificKeyIds } },
{ key_id: { notIn: inHouseTestKeyIds } },
{ key_id: { notIn: weekendKeyIds } },
{ key_id: { notIn: win32OnlyKeyIds } },
{ test_num: { notIn: exclusionTestNums } },
{ test_num: { lt: 24000 } },
],
},
where: {
AND: [
{ key_id: { in: branchKeyIds } },
{ key_id: { notIn: machineSpecificKeyIds } },
{ key_id: { notIn: inHouseTestKeyIds } },
{ key_id: { notIn: weekendKeyIds } },
{ key_id: { notIn: win32OnlyKeyIds } },
{ test_num: { notIn: exclusionTestNums } },
{ test_num: { lt: 24000 } },
],
},
but i am not getting the data that i would expect it this not the correct way to have multiple ANDs for a single field
1 Reply
Nurul
Nurul•4mo ago
Hey @thejacer87 👋 You may want to combine the notIn conditions in one filter like this:
const result = await prisma.table.findMany({
where: {
AND: [
{ key_id: { in: branchKeyIds } },
{ key_id: { notIn: [...machineSpecificKeyIds, ...inHouseTestKeyIds, ...weekendKeyIds, ...win32OnlyKeyIds] } },
{ test_num: { notIn: exclusionTestNums } },
{ test_num: { lt: 24000 } },
],
},
});
const result = await prisma.table.findMany({
where: {
AND: [
{ key_id: { in: branchKeyIds } },
{ key_id: { notIn: [...machineSpecificKeyIds, ...inHouseTestKeyIds, ...weekendKeyIds, ...win32OnlyKeyIds] } },
{ test_num: { notIn: exclusionTestNums } },
{ test_num: { lt: 24000 } },
],
},
});
If this doesn't help, what output were you expecting and what are you getting?
Want results from more Discord servers?
Add your server