在 pg-promise 的条件中使用 where 检查具有在值数组中找到的值的列
Using where in condition in pg-promise to check for columns that has a value found in an array of values
我想更新 table 并将“withdrawn”设置为 true,其中 iid 列具有在给定计算数组中找到的值。
let iids = data.map(el => el.iid);
// data is an object array with iid prop of type string
db.many('UPDATE bonuses SET withdrawn = WHERE iid IN () AND sponsor = RETURNING iid', [true, iids, email]);
//email is a preset string
当我尝试这样做时,出现以下错误:
operator does not exist: character varying = text[]
我该如何解决这个问题?
检查iid
是否属于数组参数,要使用ANY
而不是IN
:
UPDATE bonuses
SET withdrawn =
WHERE iid = ANY() AND sponsor =
RETURNING iid
我想更新 table 并将“withdrawn”设置为 true,其中 iid 列具有在给定计算数组中找到的值。
let iids = data.map(el => el.iid);
// data is an object array with iid prop of type string
db.many('UPDATE bonuses SET withdrawn = WHERE iid IN () AND sponsor = RETURNING iid', [true, iids, email]);
//email is a preset string
当我尝试这样做时,出现以下错误:
operator does not exist: character varying = text[]
我该如何解决这个问题?
检查iid
是否属于数组参数,要使用ANY
而不是IN
:
UPDATE bonuses
SET withdrawn =
WHERE iid = ANY() AND sponsor =
RETURNING iid