🎉 Stencil joins Namecheap! Read the announcement →

Uni Ecto Plugin

In your mix.exs:

defp deps do
  [
    :ecto_sql, "~> 3.0",
    :uni_ecto_plugin, "~> 0.5.0", # Hypothetical version
    :postgrex, ">= 0.0.0"
  ]
end

Run mix deps.get.

mix new my_uni_ecto_plugin --umbrella
cd apps/
mix new my_plugin --sup
cd my_plugin

Add dependencies in apps/my_plugin/mix.exs:

defp deps do
  [
    :ecto, "~> 3.9",
    :ecto_sql, "~> 3.9",
    :postgrex, "~> 0.16", optional: true
  ]
end

You expose your Ecto queries via a non-blocking interface, usually JSON over HTTP (using Phoenix) or gRPC. uni ecto plugin

# In your Elixir Phoenix Controller
def show(conn, %"id" => id) do
  # Ecto fetch (async-friendly by default in Elixir)
  user = Repo.get!(User, id)
  render(conn, "show.json", user: user)
end

In modern distributed systems, data often originates from multiple sources: different databases, microservices, or external APIs. A UNI (Universal Identifier) is a standardized way to reference any resource across these boundaries — combining type, origin, and local ID into a single string or struct.

The UNI Ecto Plugin provides seamless integration between UNI identifiers and Ecto schemas, allowing developers to:

Without such a plugin, handling UNIs in Ecto requires manual parsing, custom Ecto.Type implementations, and repetitive resolution logic. In your mix

Error: Running mix phx.server fails because no tenant is set during compilation. Fix: Guard your plugin calls:

if Mix.env() == :prod do
  UniEcto.Plugin.set_tenant_prefix("public")
end

Ecto’s preloading is crucial. Use Ecto.preload/3 as a step:

alias Uni.Ecto

step = Ecto.get(MyApp.Post, post_id) |> Ecto.preload([:comments, :author]) Run mix deps

Or pass a query with preloads directly to get/3 or list/3.