footprint v0.3.0 Footprint

TODO

  • [x] insert! and insert func.
  • [x] update! and update func.
  • [x] delete! and delete func.
  • [ ] insert_or_update! and insert_or_update func.
  • [x] get_version and get_versions func.
  • [ ] version diff and apply func.
  • [x] footprint.inspect func.

Link to this section Summary

Functions

See Footprint.VersionQueries.get_current_model/1.

See Footprint.VersionQueries.get_version/1.

See Footprint.VersionQueries.get_version/2.

See Footprint.VersionQueries.get_version/3.

See Footprint.VersionQueries.get_versions/1.

See Footprint.VersionQueries.get_versions/2.

See Footprint.VersionQueries.get_versions/3.

Same as insert/2 but returns only the model struct or raises if the changeset is invalid.

Prepase add footprint_fields_labels to origin Module.

Link to this section Functions

Link to this function

delete(struct, options \\ [meta: nil])

Same as delete/2

Examples

iex> p1 = Repo.get(Post, 1)
iex> p1 |> Footprint.delete()
{:ok, %{model: %Dummy.CMS.Post{}, version: %Footprint.Version{}}
Link to this function

delete!(struct, options \\ [meta: nil])

Sames as delete!/2

Examples

iex> p1 = Repo.get(Post, 1)
iex> p1 |> Footprint.delete!()
%Dummy.CMS.Post{}
Link to this function

get_current_model(version)

See Footprint.VersionQueries.get_current_model/1.

Link to this function

get_version(record)

See Footprint.VersionQueries.get_version/1.

Link to this function

get_version(model_or_record, id_or_options)

See Footprint.VersionQueries.get_version/2.

Link to this function

get_version(model, id, options)

See Footprint.VersionQueries.get_version/3.

Link to this function

get_versions(record)

See Footprint.VersionQueries.get_versions/1.

Link to this function

get_versions(model_or_record, id_or_options)

See Footprint.VersionQueries.get_versions/2.

Link to this function

get_versions(model, id, options)

See Footprint.VersionQueries.get_versions/3.

Link to this function

insert(changeset, options \\ [meta: nil])

Same as insert/2

Example

iex> Post.changeset(%Post{}, %{title: "t1", body: "b1"}) |> Footprint.insert()
{:ok, %{model: %Dummy.CMS.Post{}, version: %Footprint.Version{}}

iex> Post.changeset(%Post{}, %{title: "t1"}) |> Footprint.insert
{:error, :model, #Ecto.Changeset<>, %{}}
Link to this function

insert!(changeset, options \\ [meta: nil])

Same as insert/2 but returns only the model struct or raises if the changeset is invalid.

Examples

iex> Post.changeset(%Post{}, %{title: "t1", body: "b1"}) |> Footprint.insert!()
%Dummy.CMS.Post{}

iex> Post.changeset(%Post{}, %{title: "t1"}) |> Footprint.insert!()
** (Ecto.InvalidChangesetError)
Link to this function

inspect(version)

Prepase add footprint_fields_labels to origin Module.

Examples

Post.footprint_field_labels = %{title: "Title", body: "Body"} iex> version1 |> Footprint.inspect %{"Body" => [nil, "body2"], "Title" => [nil, "title1"]}

Link to this function

update(changeset, options \\ [meta: nil])

Same as update/2

Examples

iex> p1 = Repo.get(Post, 1)
iex> Post.changeset(p1, %{title: "t2"}) |> Footprint.update()
{:ok, %{model: %Dummy.CMS.Post{}, version: %Footprint.Version{}}

iex> Post.changeset(p1, %{title: "tttttt7"}) |> Footprint.update()
{:error, :model, #Ecto.Changeset<>, %{}}
Link to this function

update!(changeset, options \\ [meta: nil])

Same as update!/2

Examples

iex> p1 = Repo.get(Post, 1)
iex> Post.changeset(p1, %{title: "t2"}) |> Footprint.update()
%Dummy.CMS.Post{}

iex> Post.changeset(p1, %{title: "tttttt7"}) |> Footprint.update!()
** (Ecto.InvalidChangesetError)