View Source Versioned.Multi (Versioned v0.4.0)

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 of the returned 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(value, name)

View Source
@spec add_version_to_record({:ok, changes()} | any(), name()) ::
  {:ok, changes()} | any()

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

Link to this function

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

View Source
@spec delete(t(), name(), schema() | cs() | (changes() -> cs() | schema()), keyword()) ::
  t()

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 - The updated record itself.
  • "puppy_version" - The newly inserted version record (is_deleted=TRUE).
Link to this function

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

View Source
@spec insert(t(), name(), cs() | schema() | (changes() -> cs() | schema()), keyword()) ::
  t()

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

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

  • :puppy - The inserted record itself.
  • "puppy_version" - The inserted version record.

See Ecto.Multi.new/0.

Link to this function

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

View Source
@spec update(t(), name(), cs() | (changes() -> cs()), keyword()) :: t()

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 - The updated record itself.
  • "puppy_version" - The newly inserted version record.
  • "puppy_deletes" - List of association version records which were deleted.
  • "puppy_full" - Internal use only. A tuple with the updated record and opts including the changeset.