Part 3—Ash Framework for Phoenix Developers—Relationships part 1 | by Kamaro Lambert | Medium

The Ash framework uses the manage_relationship change within update actions to handle has_many relationship operations, allowing developers to create related records by specifying an argument containing the related data attributes and the relationship name. To implement this pattern, both the parent resource (Category) must define an update action with manage_relationship(:article_attrs, :articles, type: :create), and the child resource (Article) must accept a :create action with the required fields. The operation is executed by building a changeset with Ash.Changeset.for_update/3 and calling Ash.update/1, which atomically creates the parent record and its related child records in a single transaction.

Visit Original Article →

⌘K

Start typing to search...

Search across content, newsletters, and subscribers