Prisma不等于true,过滤错误

4
我正在运行一个prisma postgres筛选查询,如下所示。然而,当我添加不等于筛选器时,它会过滤掉所有内容并返回无结果,没有错误。我做错了什么?我有许多条目,包括is_soundtrack为false、true和null的条目。所以我应该得到一些结果。我还注释掉了另一种使用NOT的方法,但这也不起作用?
我想显示所有结果,其中is_soundtrack不等于true。
const songs = await this.db.song.findMany({
  where: {
    name: {
      contains: "test string,
    },
    // is_soundtrack: {
    //   not: true,
    // },
    NOT: {
      is_soundtrack: true,
    },
  },
  orderBy: {
    spotifyImg640: 'desc',
  }
})

“isNot: true” 过滤器可能会很有用。https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#isnot - Michael McGreal
2个回答

0
Prisma将isNot: true转换为where column <> true,但这并不起作用。
这是我不得不做的:
await prisma.questions.findMany({
    where: { OR: [{ keepHidden: false }, { keepHidden: null }] }
})

-1

我想展示所有结果,其中 is_soundtrack 不等于 true。

因此您需要:

is_soundtrack IS NOT TRUE

或者:

is_soundtrack IS DISTINCT FROM true

或者:

(is_soundtrack = false OR is_soundtrack IS NULL)

当前的过滤器 NOT is_soundtrack = true 只涵盖了 false,但是会排除 null 值。 在这里查看手册。

10
回答不是 prisma 查询,而是 PostgreSQL。 - nerkn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接