我正在尝试运行查询:
let query =
`
DELETE FROM
${table_name}
WHERE
_id IN ($1::bigint[])
AND
account_id = $2
`
let fields =
[
_ids,
account_id,
]
但这给了我错误:
operator does not exist: bigint = bigint[]
_ids
是一个数组。
实施答案后出现的错误是:
GraphQLError: Int cannot represent non-integer value: []
这只是GraphQL错误,与postgres无关。
答案 0 :(得分:2)
IN
运算符期望set of rows with exactly one column或parenthesized list of scalar expressions。它不接受数组。
One answer建议使用:list
,它告诉pg-promise做正确的事情:
WHERE _id IN ($1:list)
Another answer建议使用= any
,其中ANY
是一个接受数组的Postgres operator:
WHERE _id = ANY ($1::int[])