All Projects → woylie → ecto_nested_changeset

woylie / ecto_nested_changeset

Licence: MIT license
Helpers for manipulating nested Ecto changesets

Programming Languages

elixir
2628 projects
CSS
56736 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ecto nested changeset

Phoenix live dashboard
Realtime dashboard with metrics, request logging, plus storage, OS and VM insights
Stars: ✭ 1,657 (+7104.35%)
Mutual labels:  phoenix, ecto, liveview
ambry
Self-hosted audiobook streaming server
Stars: ✭ 38 (+65.22%)
Mutual labels:  phoenix, liveview
livebook
Automate code & data workflows with interactive Elixir notebooks
Stars: ✭ 3,402 (+14691.3%)
Mutual labels:  phoenix, liveview
google scraper live view
Application for extracting large amounts of data from the Google search results page
Stars: ✭ 17 (-26.09%)
Mutual labels:  phoenix, liveview
contextual
🌈 Generate your Ecto contexts using this macro and eliminate boilerplate
Stars: ✭ 18 (-21.74%)
Mutual labels:  phoenix, ecto
Formex
A better form library for Phoenix
Stars: ✭ 206 (+795.65%)
Mutual labels:  phoenix, ecto
query builder
Compose Ecto queries without effort
Stars: ✭ 56 (+143.48%)
Mutual labels:  phoenix, ecto
Filterable
Filtering from incoming params in Elixir/Ecto/Phoenix with easy to use DSL.
Stars: ✭ 83 (+260.87%)
Mutual labels:  phoenix, ecto
phoenix pagination
Simple pagination for Ecto and Phoenix that uses plain EEx templates.
Stars: ✭ 20 (-13.04%)
Mutual labels:  phoenix, ecto
uncharted
No description or website provided.
Stars: ✭ 31 (+34.78%)
Mutual labels:  phoenix, liveview
querie
Compose Ecto query from the client side
Stars: ✭ 20 (-13.04%)
Mutual labels:  phoenix, ecto
Phoenix Ecto Encryption Example
🔐 A detailed example for how to encrypt data in a Phoenix (Elixir) App before inserting into a database using Ecto Types
Stars: ✭ 166 (+621.74%)
Mutual labels:  phoenix, ecto
Mipha
Proj Elixir Forum build with phoenix 1.5.
Stars: ✭ 153 (+565.22%)
Mutual labels:  phoenix, ecto
Params
Easy parameters validation/casting with Ecto.Schema, akin to Rails' strong parameters.
Stars: ✭ 239 (+939.13%)
Mutual labels:  phoenix, ecto
mfpb
My Frugal PostBin
Stars: ✭ 26 (+13.04%)
Mutual labels:  phoenix, liveview
shlinked
An open-source satirical social network. shlinkedin.com
Stars: ✭ 287 (+1147.83%)
Mutual labels:  phoenix, liveview
Ecto morph
morph your Ecto capabilities into the s t r a t o s p h e r e !
Stars: ✭ 72 (+213.04%)
Mutual labels:  phoenix, ecto
Polymorphic embed
Polymorphic embeds in Ecto
Stars: ✭ 80 (+247.83%)
Mutual labels:  phoenix, ecto
algoliax
Algolia integration to elixir application
Stars: ✭ 38 (+65.22%)
Mutual labels:  phoenix, ecto
ecto profiler
Project for Ecto DB profiling
Stars: ✭ 16 (-30.43%)
Mutual labels:  phoenix, ecto

CI Hex Coverage Status

EctoNestedChangeset

This is a package for manipulating nested Ecto changesets.

Installation

Add ecto_nested_changeset to your list of dependencies in mix.exs:

def deps do
  [
    {:ecto_nested_changeset, "~> 0.2.0"}
  ]
end

Usage

The primary use case of this library is the manipulation of Ecto changesets used as a source for dynamic, nested forms in Phoenix LiveView.

category = %Category{
  posts: [
    %Post{
      id: 1,
      comments: [
        %Comment{body: "potato", id: 1},
        %Comment{body: "you", id: 2}
      ],
      title: "must"
    },
    %Post{comments: [], id: 2, title: "young"}
  ]
}

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()

%Category{
  posts: [
    %Post{
      comments: [
        %Comment{body: "Patience"},
        %Comment{body: "you", id: 2}
      ],
      id: 1,
      title: "must"
    },
    %Post{title: "have"},
    %Post{
      comments: [%Comment{body: "my"}],
      id: 2,
      title: "young"
    },
    %Post{title: "Padawan"}
  ]
}

Example application

There is an example Phoenix application with a dynamic nested LiveView form in the /example folder of the repository.

git clone https://github.com/woylie/ecto_nested_changeset.git
cd ecto_nested_changeset/example
mix setup
mix phx.server

Note that Postgres needs to be running to use the application.

You can access the application at http://localhost:4000.

Status

This library has a very narrow purpose, which means that even though it is young, it is unlikely that new functionality is going to be added or that the API is going to change. Should you miss something, though, don't hesitate to open an issue. Any issues and problems that may arise will be dealt with swiftly.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].