Store changesets before user approval

As part of a workflow I have a few (~10 to 100) changesets which are generated, then previewed to the user for them to approve. Is there a ‘standard’ way of storing these changesets between http requests so when a user pushes the approve button the exact same changesets are applied to the db.

Hello, you can see Changeset like a struct with changes.

So basically, store the changes somewhere (e.g in a GenServer). Display all changes and when a user select the « right » changes, simply cast changes to your struct (with Changeset function).

E.g

Possible changes :

  • title: « A »
  • title: « B »

If user select the first changes then call your changeset function

data = %{title: nil, content: "an example"}
YourStruct.changeset(data, %{title: "A"})

It’s an idea, for that kind of process, there is a lot of possible solutions. You can also use phœnix Channel and store the data in the client browser or use phœnix live view and store possible changes on the sockets assigns, or w.e you want.

Edit : personally I prefer the Phoenix live view solution