Uni Ecto Plugin

Let's assume you are using the popular triplex library (which implements the uni pattern) or the unifex approach. For this guide, we will use a generic setup based on the uni_ecto_plugin pattern.

defmodule MyApp.Blog.Post do
  use Ecto.Schema
  use UniEctoPlugin.SoftDelete   # adds deleted_at, soft_delete/2, restore/2

schema "posts" do field :title, :string field :body, :string timestamps() end uni ecto plugin

def changeset(post, attrs) do post |> Ecto.Changeset.cast(attrs, [:title, :body]) |> Ecto.Changeset.validate_required([:title]) end end Let's assume you are using the popular triplex

| Feature | Raw Ecto | With Contexts (no Uni) | Uni + Ecto Plugin | |---------|----------|------------------------|--------------------| | Error tracking | :error, term | :error, term | Structured Uni.Error, step name included | | Transactions | Manual Repo.transaction/1 | Nested callbacks | Declarative Ecto.transaction/2 | | Side effects | Interleaved | Mixed in functions | Separate steps, auto-halt on error | | Testability | Mox or sandbox | Partial mocks | Per-step stubs + telemetry | | Readability | with chains | Varies | Linear pipeline with named steps | | Feature | Raw Ecto | With Contexts