#_modifiedTime

3 messages · Page 1 of 1 (latest)

clever elm
#

We automatically get a _creationTime field on tables, but I would like to also have a created by, modified by, and modified time field on all my tables.

Is there a best way to approach this in Convex?

I don't mind adding boiler plate for this each time I make a table, I just want to avoid manually updating them any time I mutate a table.

Would triggers be the best approach here?

(Thanks for any advice y'all might give. 🌟 )

untold cloak
#

You could probably set up triggers https://stack.convex.dev/triggers to do this. You'd have to define a trigger for each table, but if your logic is the same across all tables you could write a reusable function and just call it in every trigger 🙂

Triggers automatically run code whenever data in a table changes. A library in the convex-helpers npm package allows you to attach trigger functions t...

clever elm
#

I don't know why I didn't think about re using a function inside the trigger definitions.

That helps get rid of most of the "ick" i had around copying and pasting logic with the triggers approach.

I'll run with this approach, thanks!