如何使用 typeorm 排除 Postgres 嵌入式数组中的所有匹配项?

How to exclude all matches in Postgres embedded array using typeorm?

我知道如何搜索包含在数组中的内容:

qb.andWhere(
  'tags.id::text[] @> (:tags)::text[]', {tags: ['foo', 'bar']}
)

但是你如何做相反的事情呢?

干脆否定它

qb.andWhere(
  'NOT(tags.id::text[] @> (:tags)::text[])', {tags: ['foo', 'bar']}
)

如果要否定查询的整个 WHERE 表达式,请用 NOT 包围所有内容(但表达式可能很长,因为所有内容都必须放在字符串中),或者使用 De Morgan 的law,其中 not (A and B) 等价于 (not A) or (not B).