Clever TaglineC
Convex Community11mo ago
43 replies
Clever Tagline

Tracking document changes

I'm porting data and logic for our business systems from Airtable to a custom app powered by Convex. Part of what Airtable provides as a standard feature is record history. This history has proved invaluable in solving problems that come up on occasion, so I need to replicate this in the new system.

I'm thinking that storing all changes in a separate table would be the way to go, with an ID field indexed to make searching for changes to a given document more efficient, and the app to use pagination to optimize the query process. The main thing that I'm struggling with is how to identify and collect the change data.

We have dozens of tables, and we'll need this history tracked on each of their documents. I really don't relish the idea of building that many separate history trackers. I'm thinking that some kind of "diff" helper function would be useful. I could pass it any document along with the changes to be saved to that document, and it would return the difference between the two as an object that I could stringify and save to the history table.

Is this doable? If so, I'd love any advice on how to make it work. My grasp of TypeScript is still pretty basic, so I can't quite wrap my head around how I'd approach something like this (if it's even possible with the current Convex design).
Was this page helpful?