Not to rush Christmas, but I think I'll try my hand at Advent of Code this year. It will be a good chance to play around with Rust.
Topic
programming
A collection of 5 posts
Adding a `soft_delete` to Ecto Multi pipelines
I'm a big fan of Ecto, Elixir's database wrapper. The Multi library lets you build up a series of operations that happen in order, if one fails the entire operation rolls back. Multi comes with the a lot of standard CRUD built in, insert/4, update/
TIL Struct matching in Guards
Not so much a TIL but I always get confused with the proper syntax. You can pattern match on a struct and use it in a guard to only let through the structs you want:
@spec address_formater(BillAddress.t() | ShipAddress.t()) :: String.t()
def address_formatter(%struct{} = address) when
TIL UUIDv4 vs UUIDv7
I've always run with UUID v4 because it's the default for the Ecto.UUID library in Elixir. However a coworker recommended UUID v7. Having never really looked into UUID other than to implement as a primary key the distinction was news to me.
Effectively;
* UUID v4
TIL INSERT INTO with SELECT constraints
In the past month I've had to write a lot of SQL to migrate a system and split existing "locations" into tenants ie. migrating data from a public schema to a tenant's schema is gets messy due to foreign key constraints. Order of operations