P
Prisma3mo ago
Emi

Prisma filter variable in given array

I have an array position:["GK","CDM","CF"] and I have a model Player { id Int @id @default(autoincrement()) name String
age Int? position String? } I need to filter position field if it has any of the given positions in position array. How should I do that? I tried this way but it doesn't work
position:
parsedFilters.positions && parsedFilters.positions.length > 0
? {
position: {
in: parsedFilters.positions,
},
}
: null,
position:
parsedFilters.positions && parsedFilters.positions.length > 0
? {
position: {
in: parsedFilters.positions,
},
}
: null,
2 Replies
Olyno
Olyno3mo ago
Hi :vmathi: What doesn't work exactly in your code? Because your code looks correct to me
Emi
Emi3mo ago
my bad, it actually works, looks like positions in my database are written differently than in array I pass😅