I'm running a prisma postgres filter query, as below. However when I add the NOT equal to filter, it ends up filtering everything and returning no results, without an error. What am I doing wrong? I have a variety of entries with both is_soundtrack false, true and null. So I should be getting some results. I also commented out another approach to using NOT
, however this also doesn't work?
I'm wanting to show all results, where is_soundtrack does not equal true.
const songs = await this.db.song.findMany({
where: {
name: {
contains: "test string,
},
// is_soundtrack: {
// not: true,
// },
NOT: {
is_soundtrack: true,
},
},
orderBy: {
spotifyImg640: 'desc',
}
})
CodePudding user response:
I'm wanting to show all results, where is_soundtrack does not equal true.
So you need:
is_soundtrack IS NOT TRUE
Or:
is_soundtrack IS DISTINCT FROM true
Or:
(is_soundtrack = false OR is_soundtrack IS NULL)
The current filter NOT is_soundtrack = true
would only cover false, but exclude null values.