Uni Ecto Plugin __hot__ Jun 2026

Let’s finish with a non-trivial example: creating a blog post with tags, ensuring tags are upserted (find or create), and linking.

defmodule MyApp.Blog.Post do use Ecto.Schema use UniEcto.Plugin # Essential step schema "posts" do field :title, :string field :body, :string field :status, :string, default: "draft" timestamps() end # Define what to broadcast def uni_broadcast_config do [ topic: "posts", events: [:create, :update, :delete] ] end end Use code with caution. Advanced Usage: Selective Broadcasting uni ecto plugin

| Ecto Feature | UNI Plugin Support | |--------------|--------------------| | Changeset validation | Custom validate_uni/3 to check resolvability or format | | Preloading | Works with belongs_to_uni like normal associations | | Streams | UNI fields are streamed as structs, no extra overhead | | Multi-tenancy | UNI origin can act as tenant ID; plugin can scope queries automatically | | Migrations | add :customer_uni, :string + optional generated columns via uni_add_components/2 | Let’s finish with a non-trivial example: creating a