
Based on the terminology, "Uni" usually refers to the Uni reactive type popularized by the Quarkus framework (Java), and "Ecto" refers to Ecto, the database wrapper and query generator for the Elixir language.
def init(default), do: default
defmodule Uni.Plugin do
@callback prepare_changeset(changeset :: Ecto.Changeset.t(), opts :: keyword()) :: Ecto.Changeset.t()
@callback before_action(action :: :insert | :update | :delete, struct :: struct(), opts :: keyword()) :: :ok, struct() | :error, term()
@callback after_action(action :: atom(), result :: term(), opts :: keyword()) :: term()
@callback modify_query(query :: Ecto.Query.t(), opts :: keyword()) :: Ecto.Query.t()
end
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. uni ecto plugin
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SoftDelete │ │ Encryption │ │ AuditTrail │
│ Plugin │ │ Plugin │ │ Plugin │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└──────────────────┼──────────────────┘
▼
┌──────────────────┐
│ Uni.Plugin.Engine│ (compile-time)
└────────┬─────────┘
▼
Your Ecto.Schema
(with plugin calls)
TV Shows (Exclusive Updates)