Hey all. I'm on Prisma 2.20.1. I want to use upd...
# orm-help
p
Hey all. I'm on Prisma 2.20.1. I want to use updateMany on a binary id.
Copy code
db.damFile.updateMany({
        data: {
          deletedAt: DateTime.utc().toString(),
        },
        where: {
          id: {
            in: ids.join(",")
          }
        },
      })
This obviously doesn't work. What's the best way to handle this use-case? I don't want to use a for loop and delete each one individually. Note: I could use an execute raw and use a string array... Thanks
t
Does it work if you just pass the
ids
as an array? Without the
.join
, because to me it feels like that should work.
p
Thanks for reply. I'm running TS and it's the wrong type.
Copy code
Type '{ in: Buffer[]; }' is not assignable to type 'Buffer | BytesFilter | undefined'.
  Object literal may only specify known properties, and 'in' does not exist in type 'Buffer | BytesFilter'.ts(2322)
If you notice. I say that using .join is the wrong way. So I'm looking for the right way using Buffer types.
t
I noticed you said it doesn't work, but an array made sense to me. Did you take a look at the type inside prisma? In VSCode you can Ctrl + Left click on the
id
property and it should take you into prismas types where you can see what can actually go into
BytesFilter
. I couldn't find this type in my prisma install, so sadly I can't help you.
p
So I have moved to using strings:
Copy code
const query = db.$executeRaw(
        `
        update DamFile
        set deletedAt = ?
        where id in (?)
      `,
        DateTime.utc().toString(),
        ids.join(",")
      )

      const result = await db.$transaction([query])

      console.log(result)
It works with one item, but doesn't work with multiple. if I do ("?") I get an error. Hopefully someone from Prisma can reply.