Batching CRUD of individual models that need to be linked


I have a few models which need to be linked together during a workflow on my webapp and I’m having trouble thinking of a nice abstraction for the api.

They are represented as individual constructs on the backend with their own CRUD methods that can be hit individually, however when the front-end saves a model it has to pull (to visualize) and push (to save) all the parts which need to be separately saved and linked together through foreign keys across tables.

I have 3 ideas for doing this so far:

  1. Batch Http requests to individual creation endpoints. (If all of the individual endpoints work I can be relatively sure that the linkages exist)
  2. Wrap the operations in a higher level nested transaction that calls the individual cruds and rollsback if any failed. Requires making linker functions that intake pairs of objects.
  3. Have a container object for the frontend that contains all the parts on the backend and define a .toBackendRep() method on it that maps those fields to their database tables

I don’t want to lose data, I want to actually test this thing, and assembling all of the parts right before serving them back to the user seems messy. If anyone has opinions on what works I’d be grateful.