#Ecto
19 notas · última:
Soft delete with Ecto 3 and Postgres
Article describes a soft delete strategy for Ecto 3 with Postgres using a deleted_at field, Postgres schemas, views, triggers, and a custom Repo.hard_delete to keep normal Ecto usage mostly unchanged.
Homemade analytics with Ecto and Elixir
The post shows how Dashbit built its own analytics to avoid cookies, first with Ecto upserts and then with Elixir processes and Registry to batch writes and reduce database pressure.
Step-by-Step Tutorial to Build a Phoenix App that Supports User Upload · Poeticoding
The article builds a Phoenix app from scratch with local file uploads, Postgres and Ecto, a Documents context, a controller for upload, list, and download actions, and a higher multipart limit.
(Ab)using Ecto as Elixir data casting and validation library
The article shows how to use Ecto changesets outside database-backed models to cast user input, validate it, and return either an action-ready changeset or typed data for service modules and forms.
Many to Many Relations in Ecto
The post shows how to model a many-to-many relation in Phoenix/Ecto with a join table, schema associations, a like action, and a query that marks whether each comment is liked by the current user.
Let's Code: Contact Form in Phoenix -- The Schema
The post builds a Phoenix contact form message as a typespec and embedded Ecto schema, then adds a changeset that casts fields, requires them, and validates the email format.
I can do all things through Postgres: Lessons for the Elixir programmer
The post argues that some application logic is better handled by Postgres than by Elixir code, using examples like constraints, citext, nearby rows, CTEs, and fuzzy search.
Kaffy
Kaffy is a flexible admin interface for Phoenix apps, with support for contexts, custom dashboards, pages, queries, search, authorization, actions, callbacks, and scheduled tasks.
The Repository Pattern, Ecto, and Database-less Testing
Explains the repository pattern in Ecto, why it helps separate data from persistence, and how to swap in a mock Repo so tests can run without a database.
A sneak peek at Ecto 3.0: breaking changes
Overview of the main breaking changes in Ecto 3.0: repo split into ecto and ecto_sql, switch to Elixir calendar types, and new JSON handling via adapters.
When to Use Constraints in Ecto
The post explains when Ecto validations are enough and when database constraints are needed, showing that constraints give stronger guarantees for uniqueness, ordering, and overlap, but can reduce flexibility and user experience.
Fragments in Ecto
The post shows how to query date ranges in Ecto by using `fragment/1` with Postgres `OVERLAPS`, plus `type/2` to tell Ecto the date types it cannot infer.
Folding Window Functions Into Ecto
The post shows how to rank trips by category with PostgreSQL window functions, then reproduce the query in Ecto 2.0 using raw SQL and tests, comparing it with a naive in-memory approach.
Phoenix, to the basics and beyond.
The post outlines a short set of Phoenix topics beyond the default generators: editor setup, model definitions, custom primary keys and validators, and a Repository-based approach with macros.
What I learned migrating a Rails app to Elixir/Phoenix
The migration favors small functions, explicit composition, and Phoenix idioms over Rails patterns. It also shows where the ecosystem is thinner and where custom integrations or rewrites are needed.
Building a web framework from scratch in Elixir
The article shows how to build a small Sinatra-like web framework in Elixir with Plug, covering requests, routing, macros, templates, Ecto models, testing, and performance.
Postgres Full Text Search in Ecto
The post shows how to add username search in an Ecto model with Postgres pg_trgm, including a GIN index, a composable query function, and a note on using similarity when the % operator limit must be set per query.
Doubts about layers and application's organization
A thread about how to organize Elixir code with Phoenix and Ecto. José Valim and others advise delaying architecture decisions, avoiding premature optimization, and separating database queries into explicit query modules.
Build and test a blazing fast JSON API with Phoenix, an Elixir framework
The article shows how to build a Phoenix JSON API for contacts, starting with a test, then adding an Ecto model, migration, route, controller, and view until the test passes.
