🧹
postgresqlで値の組み合わせ一致で複数削除する
以下
delete from mytable where (id1, id2) = ANY(Array [(1,3), (2,1)]);
prismaなら以下
const arrSql = Prisma.join(
targets.map(target => Prisma.sql`(${Prisma.join([target.type, target.id])})`)
);
await prisma.$executeRaw`DELETE FROM my_table WHERE some_key = ${someKey} AND (target_type, target_id) = ANY(ARRAY [${arrSql}])`;
Discussion