Hello everyone! When I do this: ```this.prisma.mes...
# orm-help
o
Hello everyone! When I do this:
Copy code
this.prisma.message.updateMany({
  where: {
    chat_id: chatId,
    sender: {
      not: sender,
    },
    created_at: {
      lte: lastReadMessageCreatedAt,
    },
  },
  data: {
    read_at: new Date(),
  },
});
Prisma firstly selects all the message ids for messages which match the query, and then updates messages with
IN (...message ids)
approach
Copy code
UPDATE `message` SET `read_at` = '2022-09-13 07:47:00.288000' WHERE `message`.`id` IN ('ecdf8353-ce11-44ff-891c-8491bf1f736b','ecdfac6a-325a-4b6d-9425-e16d4064c467','ecdfb9a1-ba26-4e81-8e56-a5daf0dfab5b','ece0b1d7-388d-4cbd-8b5a-06628d39a6b9','ece220d8-f8b9-4fd6-ac05-2844d60685aa','ece32bf9-f867-46f9-b901-7692e41ba67f','ece84045-0fb1-478b-8b82-82db4273ae49','ece898dd-a299-4df8-88c3-61e20fd7087a','ecead321-3ec3-4901-861c-d39b2decee6a','ecebee42-255c-4210-9934-db2b2ac857e6','ecec2422-b48b-4825-a8b8-1ca30de678cc','ecee5f77-63ba-45d9-829d-0e293d1780fe', ... and so on)
Is it possible to make such an update using one query without using queryRaw? Also, would be nice, if you share the reason for this behavior) Thanks
✅ 1
a
Hey Oleksii! Are you experiencing an issue with the current approach? Bad performance? I’m not aware of any way to customize this behavior without using
$queryRaw
v
👋 Hello @Oleksii Rumiantsev, did you have a chance to read Austin comment? Let us know if you're still experiencing this issue!
o
Hi, Yes, there were an issue with bad performance. So we used
$queryRaw
, as was proposed Thank you)
🙌 1
v
Fantastic, thank you for confirming that was the solution (for now!) 🙂