I just published a new post on the Slab blog, covering a little-known feature in Ecto!
To give a quick overview, Ecto lets you specify default fields for associations in the
schema definitions, but what’s super-interesting is that the
:default option can also
accept an MFA tuple, allowing you to execute custom logic to build the aossication.
What’s even better is that this works with pivot tables (
:through associations) as
well! This has wide range of use-cases like multi-tenancy, security, reliability,
database sharding, and more.
The post got featured in various newsletters:
A few days back I wrote about an obscure little #ecto feature we use at @slab: https://t.co/xrF7JdDKD7— Sheharyar Naseer (@sheharyarn) March 31, 2021
While the post only covers the usage, I want to give a quick overview of our use-case. 1/#myelixirstatus #elixirlang