Versioned.Multi (Versioned v0.3.2) View Source

Tools for operating on versioned records.

Link to this section Summary

Functions

To be invoked after Repo.transaction/1. If successful, the id of "_version" will be attached to the :version_id field of "_record".

Returns an Ecto.Multi with all steps necessary to delete a versioned record.

Returns an Ecto.Multi with all steps necessary to insert a versioned record.

Returns an Ecto.Multi with all steps necessary to update a versioned record.

Link to this section Functions

Link to this function

add_version_to_record(error, name)

View Source

Specs

add_version_to_record({:ok, map()} | any(), String.t()) :: {:ok, map()} | any()

To be invoked after Repo.transaction/1. If successful, the id of "_version" will be attached to the :version_id field of "_record".

Link to this function

delete(multi, name, struct_or_changeset, opts \\ [])

View Source

Specs

Returns an Ecto.Multi with all steps necessary to delete a versioned record.

An Ecto.Multi is returned which first updates the record itself, inserts a new version into the versions table and finally deletes associations as needed.

If name is "puppy", the returned parts will be:

  • "puppy_record" - The updated record itself.
  • "puppy_version" - The newly inserted version record (is_deleted=TRUE).
Link to this function

insert(multi, name, struct_or_changeset, opts \\ [])

View Source

Specs

Returns an Ecto.Multi with all steps necessary to insert a versioned record.

If name is "puppy", the returned parts will be:

  • "puppy_record" - The inserted record itself.
  • "puppy_version" - The inserted version record.
Link to this function

update(multi, name, changeset, opts \\ [])

View Source

Specs

Returns an Ecto.Multi with all steps necessary to update a versioned record.

An Ecto.Multi is returned which first updates the record itself, inserts a new version into the versions table and finally deletes associations as needed.

If name is "puppy", the returned parts will be:

  • "puppy_record" - The updated record itself.
  • "puppy_version" - The newly inserted version record.
  • "puppy_deletes" - List of association version records which were deleted.