Below you will find pages that utilize the taxonomy term “elixir”
Posts
Updating deeply nested elixir maps
In some cases it is necessary to update a deeply nested attribute in a map. I went searching for a way to do this and came across several approaches, the one that worked for me was this, a combination of Kernel.put_in and Access.key, here I’m using it to update a socket struct nested assigns map.
put_in(socket, Enum.map([:assigns, :beacon_live_data, :form_submitted], &Access.key(&1, %{})), true) The put_in function is pretty easy to understand, it Puts a value in a nested structure via the given path.
Posts
Decoding TypeORM-Encrypted Data With Elixir
Today’s challege was to figure out how to decrypt an encrypted field created by the TypeORM plugin typeorm-encrypted. Typeorm-encrypted allows you to automatically encrypt/decrypt a field on save/fetch when using TypeORM. This allows you to encrypt sensitive data while at rest in your database.
The Typeorm-encrypted module saves the encrypted (aes-256-gcm) field as a Base64 encoded string in the database. Our challege is to be able to read that field from our database and decrypt the sensitive data for use in our Elixir application.