verex v0.1.0 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

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.

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. Return either: -> {:ok, changes} -> {: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