Uni Ecto Plugin Info

Uni Ecto Plugin Info

The combination of and Ecto offers the best of both worlds:

def change do create table(:items) do add :id, :uni_id add :payload, :uni_json timestamps() end end

defmodule UniEctoPlugin.SoftDeleteTest do use ExUnit.Case, async: true alias Ecto.Adapters.SQL.Sandbox # Setup a test repo (see full example in Appendix) uni ecto plugin

To inject fields or macros into an Ecto Schema, your plugin leverages Elixir macros. This allows you to automatically append standard fields like tenant_id , deleted_at (for soft deletes), or tracking metrics.

def before_insert(changeset, tenant_id) do set_tenant(changeset, tenant_id) end end The combination of and Ecto offers the best

: The plugin includes mechanisms for ensuring data integrity across the application. This encompasses better support for transactions, data validations, and automatic handling of certain data consistency issues.

Seamlessly chain multiple plugins together without merge conflicts in your changesets. Core Architecture and Installation This encompasses better support for transactions

# 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

Define behavior once and inject it across dozens of schemas.