Is there currently a way to utilize onUpdate?

Trying to run ON UPDATE NOW() for a last_updated column for whenever the row is changed.
5 Replies
bloberenober
bloberenober15mo ago
There's an .onUpdateNow() method
JT
JT15mo ago
FYI, this is not mentioned in the docs anywhere.
bloberenober
bloberenober15mo ago
Fair It's visible via the method autocompletion though The docs will be improved significantly once we prepare the website
Cory
Cory15mo ago
awesome I'll give it a shot!
Md Jahidul Islam milon
updatedAt: timestamp('updated_at', { mode: 'date', precision: 3 }) .defaultNow() .$onUpdate(() => sql(now() AT TIME ZONE 'UTC')) .notNull(), can we add .$onUpdate(() => sql(now() AT TIME ZONE 'UTC')) this?