erquhartE
Convex Community2y ago
72 replies
erquhart

I have a file full of helper functions

I have a file full of helper functions for every table. Mostly crud stuff, listing, pagination, etc. Boring "db layer" stuff. For every get-by-id, which occurs many times throughout each file, I use a shared utility function that throws if the id is not found.

Then I started having to deal with what happens when something - literally anything - gets deleted. (Things crash.) I've been avoiding this for months, but I'm now convinced this was absolutely the wrong approach. I've now changed that function to just return undefined, and am updating my entire application to handle it.

Throwing this out there in case anyone else is thinking through this sort of thing, and of course, in case anyone has helpful thoughts on the matter.
Was this page helpful?