if i got a prisma field like this: `roleIds: Strin...
# orm-help
f
if i got a prisma field like this:
roleIds: String[]
How can I delete 1 value from many users?
Copy code
await prisma.serverMember.updateMany({where: {roleIds: {has: roleId}}, data: {
  roleIds: // what goes here?
}});
👀 1
✅ 1
Can anyone help me??
r
Hi @Fishie 👋 There's no method to splice/remove items from a scalar list using Prisma. You would have to fetch the scalar list from your database, modify it manually in your application code and overwrite the record in your database with an
update
operation. There is a feature request for this, please feel free to follow/comment with your use-case to help us track demand for this feature.
Also a workaround was specified in the github issue as well.
f
Yikes, why does prisma have so many lacking features
so annoying
i regret moving away from mongoose
the solution you provide sounds so inefficient.
if there are 1000 entries, i have to fetch each member manually and update each roleIds array. wow
its 2022 guys
r
Did you have a chance to look at this
Copy code
UPDATE table_name 
SET column_name=(array_remove(column, 'keyword to be removed')) 
WHERE 'keyword to be removed' = ANY(column_name);
f
and how do i run that in js?
r
You would need to use Prisma queryRaw
f
ty
r
You're welcome.