So I have given up my previous question with Buffe...
# orm-help
p
So I have given up my previous question with Buffers and now instead trying to use string. I keep on getting 0 changes when I am submitting a multiple item array, just 1 item and it's fine.
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)
Can anyone catch what I am doing wrong? Thanks
r
You need to use
join
as shown here. This can be imported from:
Copy code
import { Prisma } from '@prisma/client';

Prisma.join
p
Thanks for the response. I have tried that, but let me try it again.
Doesn't work. The deletedAt does not change. Is there a way to debug this? Thanks
This is my input and output:
Copy code
[
  '01FB6VB2G907FMJ91P88VXGA4S',
  '01FB6VB4XWA2YKJWVZ7KADQF56',
  '01FB6VB6W349W5SHTNSE39674X',
  '01FB6VB95R8QB2SXAX87GVC7KY',
  '01FB6VBAYKAYG0Y80DKJ4SQXQN'
]
[ 0 ]
Just so you are aware I'm on 2.20.1. I am unable to upgrade past this due to an issue with Binary ids.
r
Is the datatype of your field
Bytes
?
p
Yes
If you scroll up a ways, I have investigated it doing it via updateMany but couldn't quite grok it. 😀
Copy code
db.damFile.updateMany({
        data: {
          deletedAt: DateTime.utc().toString(),
        },
        where: {
          id: {
            in: ids.join(",")
          }
        },
      })
I didn't know how to substitute the ids.join for usage with buffers
r
Could you share some sample data that you’re passing? I would like to try this out.
p
Let me know if this is ok or you need more stuff. https://gist.github.com/paulm17/74dfb747794357bc6e8e4ceec807523d
Hey, so any luck?
r
I cannot insert the values you provided using
Buffer
.
p
This is how I save for that table:
Copy code
const query = this.prisma.damFile.create({
        data: {
          id: Buffer.from(data.fileId),
          userId: Buffer.from(data.userId),
          parentId: Buffer.from(data.parentId),
          typeId: Buffer.from(data.fileTypeId),
          mimeId: Buffer.from(data.mimeId),
          name: data.filename,
          filename: data.filename,
          filesize: data.size,
          extension: data.extension,
          md5: data.tempFileMd5,
          filterType: data.fileType,
        },
        select: { id: true },
      });

      const result = await this.prisma.$transaction([query]);
Table:
Copy code
model DamFile {
  id                Bytes     @id @db.Binary(26)
  parentId          Bytes?    @db.Binary(26)
createdAt         DateTime  @default(now())
r
Yeah but the data from the gist cannot be saved. I’m getting an error:
p
I'm running 2.20.1 and I can't upgrade because of it
Could you ask the team what's the progress of the ticket? Thanks
@Ryan Hey any update? Should I make an issue on github? Thanks
r
Yes it would be great if you could create one here 🙂