Understanding Associations in Elixir's Ecto
blog.appsignal.com
blog.appsignal.com
I just shared it here: https://news.ycombinator.com/item?id=25066424
Would recommend people checkout the list: https://alchemist.camp/episodes
I've been listening to the other person on the podcast (Justin Vincent) other podcast, Techzing, for many years.
See "Constraints and Upserts" as well as "Polymorphic associations with many to many".
Comments for that reason aren't a good use case for put_assoc, because generally you add a comment one at a time. It makes more sense to just create a new comment with the associated post ID.
Also the string keys in structs weirded me out - I don't think that works in Elixir.
Not being familiar with Ecto or Elixir (and only moderately familiar with Erlang), I would expect anything named `put` to be a full replacement. That's what I associate with the same verb in HTTP semantics, as well as in general FP semantics. It seems like a welcome place for an abstraction like `cons`, but I think even that may get into impedance mismatch territory...