Database.Persist and `lastUpdate`
As far as I know, Database.Persist
don't work for any auto-updateable field ( Yesod Book Persistent ).
But there is one special case on it (at least for me: P) this field lastUpdate :: UTCTime
(I like it and I used data changes extensively).
In addition, this update must be done at the database level (if not, all servers must be fully synchronized [this is difficult and weak], and record writes must be done within a transaction to include a system call getTime
[ineffective]).
My current solution is to create ( manually ) the trigger.
Do you know the best way to do this?
Thank!
source to share
Since this looks so important to you, relying on the database now()
is safest, as this will consistently use the start of the transaction as the return value. If you calculate the time in the application itself, you will have to be very careful to pass the same value everywhere.
You can look into Haskell's esqueleto library to structure the sql in such a way that you always have an extra call set
to the column lastUpdate
. I don't think it currently provides sql function now()
, so you can add it to lib.
source to share