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
Same as delete/2
Sames as delete!/2
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
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.
Same as update/2
Same as update!/2
Link to this section Functions
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{}}
delete!(struct, options \\ [meta: nil])
Sames as delete!/2
Examples
iex> p1 = Repo.get(Post, 1)
iex> p1 |> Footprint.delete!()
%Dummy.CMS.Post{}
get_current_model(version)
See Footprint.VersionQueries.get_current_model/1
.
get_version(record)
See Footprint.VersionQueries.get_version/1
.
get_version(model_or_record, id_or_options)
See Footprint.VersionQueries.get_version/2
.
get_version(model, id, options)
See Footprint.VersionQueries.get_version/3
.
get_versions(record)
See Footprint.VersionQueries.get_versions/1
.
get_versions(model_or_record, id_or_options)
See Footprint.VersionQueries.get_versions/2
.
get_versions(model, id, options)
See Footprint.VersionQueries.get_versions/3
.
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<>, %{}}
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)
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"]}
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<>, %{}}
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)