dwyl / alog

🌲 alog (Append-only Log) is an easy way to start using the Lambda/Kappa architecture in your Elixir/Phoenix Apps while still using PostgreSQL (with Ecto).
GNU General Public License v2.0
15 stars 2 forks source link

Improve update function #10

Open Danwhy opened 5 years ago

Danwhy commented 5 years ago

Currently we've had to override the update function for a few of our modules in CS, because we need to add in the many_to_many or one_to_many associations.

It should be possible to abstract this out into this module, by using __MODULE__.__schema__(:associations) to get all of the associations, then map through that with __MODULE__.__schema__(:association, assoc) to get detailed information on each association, including whether it's a many_to_many, one_to_many etc, then comparing it with the updated attributes and dealing with any updated associations in the appropriate way.