Uni Ecto Plugin 🆕 Easy

Uni Ecto Plugin offers a clean, extensible, and Elixir‑idiomatic way to add cross-cutting database behaviours. By moving from ad‑hoc macros to a standard behaviour-based plugin system, we reduce boilerplate, improve composability, and keep Ecto’s explicit philosophy intact. We invite the community to contribute plugins and feedback.


Ecto returns :error, changeset. But what about validation errors vs. database constraint errors vs. connection errors? Uni normalizes all Ecto errors into a standard Uni.Error.t() structure. uni ecto plugin

| Practice | Reason | |----------|--------| | Use __using__/1 macros | Clean integration into schemas | | Provide a behaviour | Enables custom implementations | | Add query helpers | E.g., MyPlugin.not_deleted(query) | | Avoid hardcoded repo | Pass repo as argument (soft_delete(struct, repo)) | | Support optional fields | Use field :deleted_at, :utc_datetime_usec inside using | | Write extensive tests | Test with real sandboxed repo | | Document all macros & helpers | Include usage examples | | Version semantically | Breaking changes = major version | Uni Ecto Plugin offers a clean, extensible, and


| 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 | Ecto returns :error, changeset