verex v0.1.2 Verex.Repo

Verex.Repo performs all the Repo transactions. Prior to any repo transactions, alterations to the changeset are made to allow for proper versioning.

Summary

Functions

Verex custom delete function

Verex custom insert function

Overloaded Verex custom insert function

Verex custom update function

An overloaded Verex custom update function

Functions

delete(changeset)
delete(struct_or_changeset :: Ecto.Schema.t | Ecto.Changeset.t) ::
  {:ok, Ecto.Schema.t} |
  {:error, Ecto.Changeset.t}

Verex custom delete function.

Since we want a history of all entries for this module, we do not want to delete from the repo. Rather, the delete function will simply inactivate the changeset passed in.

This will return the result of a Repo.Update function.

insert(changeset)
insert(struct_or_changeset :: Ecto.Schema.t | Ecto.Changeset.t) ::
  {:ok, Ecto.Schema.t} |
  {:error, Ecto.Changeset.t}

Verex custom insert function.

Insert new changeset into repo defined during Verex configuration. Will first perform necessary adjustments to changeset such as activating this version. All other Verex-customized attributes are modified accordingly.

Returns the result of Repo.Insert on changeset.

insert(changeset, parent_id)
insert(struct_or_changeset :: Ecto.Schema.t | Ecto.Changeset.t, integer) ::
  {:ok, Ecto.Schema.t} |
  {:error, Ecto.Changeset.t}

Overloaded Verex custom insert function.

Performs same functionality as normal Verex insert function. However, allows the inserted record to be appended to an old outdated version. This is done by passing an extra parameter parent_id. The new appended record will not be a new version itself, but rather continue a sequenced version from earlier in time.

update(changeset)
update(struct_or_changeset :: Ecto.Schema.t | Ecto.Changeset.t) ::
  {:ok, any} |
  {:error, any} |
  {:error, atom, any, %{optional(atom) => any}}

Verex custom update function.

Must perform two Repo Transactions that will either both successfully commit, or neither will.

  • Update current entry in repo to be inactive.
  • Insert new changeset with correspoding parent_id.

    Both operations must be successful for any changes to the repo to be made. Returns resulf of a Repo.transaction on the list of operations defined in an Ecto.Multi. Returns either {:ok, changes} or {:error, failed_operation, failed_value, changes_so_far}

update(new_changeset, old_changeset)
update(struct_or_changeset :: Ecto.Schema.t | Ecto.Changeset.t, struct_or_changeset :: Ecto.Schema.t | Ecto.Changeset.t) ::
  {:ok, any} |
  {:error, any} |
  {:error, atom, any, %{optional(atom) => any}}

An overloaded Verex custom update function.

Rather than passing in a single changeset, this allows the user to make custom modifications to the entry already in the repo. Accepts the new_changeset and the old_changeset.

Will perform the same Repo.transactions as Verex.update(changeset). Will no longer retrieve the old_changeset from the repo.

Options

Verex.Repo.update will accept the same options as Repo.update