EctoNestedChangeset - Helpers for manipulating nested Ecto changesets

ecto_nested_changeset is a library for manipulating nested Ecto changesets. It was made to simplify building dynamic forms with nested resources.

The repository includes a demo application with a nested LiveView form.

import EctoNestedChangeset

category
|> Ecto.Changeset.change()
|> append_at(:posts, %Post{title: "Padawan", comments: []})
|> prepend_at([:posts, 0, :comments], %Comment{body: "ecneitaP"})
|> delete_at([:posts, 0, :comments, 1], mode: {:action, :delete})
|> insert_at([:posts, 1], %Post{title: "have"})
|> append_at([:posts, 2, :comments], %Comment{body: "my"})
|> update_at([:posts, 0, :comments, 0, :body], &String.reverse/1)
|> Ecto.Changeset.apply_changes()
4 Likes