hi all, i have an array of id `const ids = ["id1"...
# orm-help
j
hi all, i have an array of id
const ids = ["id1", "id2"]
So how can i pass it to `prisma.$executeRaw`UPDATE users SET level=1 WHERE id IN (ids)`` ? thank you
đź‘€ 1
âś… 1
n
Hey 👋 Did you try adding ids through template literals as mentioned here? Like: `prisma.$executeRaw`UPDATE users SET level=1 WHERE id IN (${ids})` Depending on your database you might need to add schema name with table name as well. For Example it could be “public”.“users” instead of users.
j
thank you response, I've tried
ids.join(",")
but it not work, the problem is i cannot convert
ids
to SQL syntax
WHERE id IN ('id1', 'id2')
. Let me check with your suggest
WHERE id IN (${ids})
s
WHERE id IN (${Prisma.join(ids)})
This should work