Hi there, a quick question about `@updatedAt` - it...
# orm-help
r
Hi there, a quick question about
@updatedAt
- it seems the timestamp gets updated on every update of the record, even when the new dataset is exactly the same as the origin one. Is there any way to exclude empty updates on Prisma/ORM level, so the updatedAt considers only real delta in the update scenario? I guess, this would give us less redundancy and additional a performance bonus.
r
Does this occur when you’re passing the same data to
update
?
r
@Ryan exactly, Prisma simply updates
updatedAt
field on every
update
, no matter whether the new data differ from the origin one, or not.
r
Prisma currently doesn’t compare data to see if the data you passed in
update
matches the existing data. You would need to check this in the application itself before calling
update
I would suggest creating a feature request here with your use case so that we can look into this 🙂
r
ok, I will create a feature request. Actually the main reason to use
updatedAt
was to notify other services about new changes of the nested data. Previously we could use prisma1 subscriptions, now we try via prisma2 middleware: 1. we check the payload if it matches the relevant criteria 2. after saving in DB we wanted to check
updatedAt
of nested entities whether their timestamp was updated. 3. if so, then we send an notification to other services. But it looks like we can't rely on
updatedAt
, otherwise we'll end up with many redundant notifications (in case of empty updates, which we unfortunately can't avoid). Any suggestions though?
r
In Prisma 1 subscriptions, didn’t the subscription fire if you called
update
with the same data? An update call with any data should mean that the item has been updated as subscriptions do not check for the previous value. Unfortunately the only way to do this would be in your application logic. Check if the values are same and don’t fire the update at all if they match.
r
thanks, we will do 👍